mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-26 19:21:20 -08:00
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).
This commit is contained in:
parent
a79d21c83e
commit
6e11570862
@ -40,11 +40,11 @@ class Interface : public Kernel::Session {
|
|||||||
* Creates a function string for logging, complete with the name (or header code, depending
|
* Creates a function string for logging, complete with the name (or header code, depending
|
||||||
* on what's passed in) the port name, and all the cmd_buff arguments.
|
* on what's passed in) the port name, and all the cmd_buff arguments.
|
||||||
*/
|
*/
|
||||||
std::string MakeFunctionString(const std::string& name, const std::string& port_name, const u32* cmd_buff) {
|
std::string MakeFunctionString(const char* name, const char* port_name, const u32* cmd_buff) {
|
||||||
// Number of params == bits 0-5 + bits 6-11
|
// Number of params == bits 0-5 + bits 6-11
|
||||||
int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F);
|
int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F);
|
||||||
|
|
||||||
std::string function_string = Common::StringFromFormat("function '%s': port=%s", name.c_str(), port_name.c_str());
|
std::string function_string = Common::StringFromFormat("function '%s': port=%s", name, port_name);
|
||||||
for (int i = 1; i <= num_params; ++i) {
|
for (int i = 1; i <= num_params; ++i) {
|
||||||
function_string += Common::StringFromFormat(", cmd_buff[%i]=%u", i, cmd_buff[i]);
|
function_string += Common::StringFromFormat(", cmd_buff[%i]=%u", i, cmd_buff[i]);
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public:
|
|||||||
struct FunctionInfo {
|
struct FunctionInfo {
|
||||||
u32 id;
|
u32 id;
|
||||||
Function func;
|
Function func;
|
||||||
std::string name;
|
const char* name;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,13 +76,13 @@ public:
|
|||||||
|
|
||||||
if (itr == m_functions.end() || itr->second.func == nullptr) {
|
if (itr == m_functions.end() || itr->second.func == nullptr) {
|
||||||
std::string function_name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name;
|
std::string function_name = (itr == m_functions.end()) ? Common::StringFromFormat("0x%08X", cmd_buff[0]) : itr->second.name;
|
||||||
LOG_ERROR(Service, "%s %s", "unknown/unimplemented", MakeFunctionString(function_name, GetPortName(), cmd_buff).c_str());
|
LOG_ERROR(Service, "unknown / unimplemented %s", MakeFunctionString(function_name.c_str(), GetPortName().c_str(), cmd_buff).c_str());
|
||||||
|
|
||||||
// TODO(bunnei): Hack - ignore error
|
// TODO(bunnei): Hack - ignore error
|
||||||
cmd_buff[1] = 0;
|
cmd_buff[1] = 0;
|
||||||
return MakeResult<bool>(false);
|
return MakeResult<bool>(false);
|
||||||
} else {
|
} else {
|
||||||
LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName(), cmd_buff).c_str());
|
LOG_TRACE(Service, "%s", MakeFunctionString(itr->second.name, GetPortName().c_str(), cmd_buff).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
itr->second.func(this);
|
itr->second.func(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user