diff options
| author | 2015-01-30 17:15:02 -0200 | |
|---|---|---|
| committer | 2015-02-02 15:37:00 -0200 | |
| commit | 6e11570862e184a10b7954ec26e0d70b9e0c2def (patch) | |
| tree | ad7c45c695f4399bf7dc0281947500b32212f996 | |
| parent | Service: Clean-up Interface (diff) | |
| download | yuzu-6e11570862e184a10b7954ec26e0d70b9e0c2def.tar.gz yuzu-6e11570862e184a10b7954ec26e0d70b9e0c2def.tar.xz yuzu-6e11570862e184a10b7954ec26e0d70b9e0c2def.zip | |
Service: Store function names as const char* instead of std::string
Uses less memory (strings and function table is stored in constant data)
and speeds up start up (no need to allocate and copy strings).
| -rw-r--r-- | src/core/hle/service/service.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 121e69932..3370f9f9b 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -29,7 +29,7 @@ static const int kMaxPortSize = 8; ///< Maximum size of a port name (8 character | |||
| 29 | class Manager; | 29 | class Manager; |
| 30 | 30 | ||
| 31 | /// Interface to a CTROS service | 31 | /// Interface to a CTROS service |
| 32 | class Interface : public Kernel::Session { | 32 | class Interface : public Kernel::Session { |
| 33 | // TODO(yuriks): An "Interface" being a Kernel::Object is mostly non-sense. Interface should be | 33 | // TODO(yuriks): An "Interface" being a Kernel::Object is mostly non-sense. Interface should be |
| 34 | // just something that encapsulates a session and acts as a helper to implement service | 34 | // just something that encapsulates a session and acts as a helper to implement service |
| 35 | // processes. | 35 | // processes. |
| @@ -40,11 +40,11 @@ class Interface : public Kernel::Session { | |||
| 40 | * Creates a function string for logging, complete with the name (or header code, depending | 40 | * Creates a function string for logging, complete with the name (or header code, depending |
| 41 | * on what's passed in) the port name, and all the cmd_buff arguments. | 41 | * on what's passed in) the port name, and all the cmd_buff arguments. |
| 42 | */ | 42 | */ |
| 43 | std::string MakeFunctionString(const std::string& name, const std::string& port_name, const u32* cmd_buff) { | 43 | std::string MakeFunctionString(const char* name, const char* port_name, const u32* cmd_buff) { |
| 44 | // Number of params == bits 0-5 + bits 6-11 | 44 | // Number of params == bits 0-5 + bits 6-11 |
| 45 | int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F); | 45 | int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F); |
| 46 | 46 | ||
| 47 | std::string function_string = Common::StringFromFormat("function '%s': port=%s", name.c_str(), port_name.c_str()); | 47 | std::string function_string = Common::StringFromFormat("function '%s': port=%s", name, port_name); |
| 48 | for (int i = 1; i <= num_params; ++i) { | 48 | for (int i = 1; i <= num_params; ++i) { |
| 49 | function_string += Common::StringFromFormat(", cmd_buff[%i]=%u", i, cmd_buff[i]); | 49 | function_string += Common::StringFromFormat(", cmd_buff[%i]=%u", i, cmd_buff[i]); |
| 50 | } | 50 | } |
| @@ -59,7 +59,7 @@ public: | |||
| 59 | struct FunctionInfo { | 59 | struct FunctionInfo { |
| 60 | u32 id; | 60 | u32 id; |
| 61 | Function func; | 61 | Function func; |
| 62 | std::string name; | 62 | const char* name; |
| 63 | }; | 63 | }; |
| 64 | 64 | ||
| 65 | /** | 65 | /** |
| @@ -76,13 +76,13 @@ public: | |||
| 76 | 76 | ||
| 77 | if (itr == m_functions.end() || itr->second.func == nullptr) { | 77 | if (itr == m_functions.end() || itr->second.func == nullptr) { |
| 78 | std::string function_name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name; | 78 | std::string function_name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name; |
| 79 | LOG_ERROR(Service, "%s %s", "unknown/unimplemented", MakeFunctionString(function_name, GetPortName(), cmd_buff).c_str()); | 79 | LOG_ERROR(Service, "unknown / unimplemented %s", MakeFunctionString(function_name.c_str(), GetPortName().c_str(), cmd_buff).c_str()); |
| 80 | 80 | ||
| 81 | // TODO(bunnei): Hack - ignore error | 81 | // TODO(bunnei): Hack - ignore error |
| 82 | cmd_buff[1] = 0; | 82 | cmd_buff[1] = 0; |
| 83 | return MakeResult<bool>(false); | 83 | return MakeResult<bool>(false); |
| 84 | } else { | 84 | } else { |
| 85 | LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName(), cmd_buff).c_str()); | 85 | LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str()); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | itr->second.func(this); | 88 | itr->second.func(this); |