mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-05 19:51:45 +00:00
setsys_settings_items: Less resource churn with combined key/value construction
The previous string construction discards two temporary std::string instances (operator+ returns by value, not by reference), and creates a std::string that it doesn't need to (the one around key). Instead we can just append to the end of the initial std::string itself, saving on two unnecessary created strings. append() has a const char* overload as well (as does operator+), so we can just append the key string as is without creating an entire new string.
This commit is contained in:
parent
452c61db7a
commit
dd10547ac2
1 changed files with 10 additions and 10 deletions
|
@ -154,7 +154,7 @@ static Result ParseValue(const char *name, const char *key, const char *val_tup)
|
|||
return ResultSettingsItemValueInvalidFormat;
|
||||
}
|
||||
|
||||
std::string kv = std::string(name) + "!" + std::string(key);
|
||||
std::string kv = std::string(name).append("!").append(key);
|
||||
SettingsItemValue value;
|
||||
|
||||
if (strncasecmp(type, "str", type_len) == 0 || strncasecmp(type, "string", type_len) == 0) {
|
||||
|
@ -275,7 +275,7 @@ void SettingsItemManager::LoadConfiguration() {
|
|||
}
|
||||
|
||||
Result SettingsItemManager::GetValueSize(const char *name, const char *key, u64 *out_size) {
|
||||
std::string kv = std::string(name) + "!" + std::string(key);
|
||||
const std::string kv = std::string(name).append("!").append(key);
|
||||
|
||||
auto it = g_settings_items.find(kv);
|
||||
if (it == g_settings_items.end()) {
|
||||
|
@ -287,7 +287,7 @@ Result SettingsItemManager::GetValueSize(const char *name, const char *key, u64
|
|||
}
|
||||
|
||||
Result SettingsItemManager::GetValue(const char *name, const char *key, void *out, size_t max_size, u64 *out_size) {
|
||||
std::string kv = std::string(name) + "!" + std::string(key);
|
||||
const std::string kv = std::string(name).append("!").append(key);
|
||||
|
||||
auto it = g_settings_items.find(kv);
|
||||
if (it == g_settings_items.end()) {
|
||||
|
|
Loading…
Reference in a new issue