mirror of
https://git.h3cjp.net/H3cJP/citra.git
synced 2024-12-02 08:53:24 +00:00
param_package: Use std::unordered_map's insert_or_assign instead of map indexing
This avoids a redundant std::string construction if a key doesn't exist in the map already. e.g. data[key] requires constructing a new default instance of the value in the map (but this is wasteful, since we're already setting something into the map over top of it).
This commit is contained in:
parent
290bfa1804
commit
5b691d3fe0
|
@ -103,15 +103,15 @@ float ParamPackage::Get(const std::string& key, float default_value) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, const std::string& value) {
|
void ParamPackage::Set(const std::string& key, const std::string& value) {
|
||||||
data[key] = value;
|
data.insert_or_assign(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, int value) {
|
void ParamPackage::Set(const std::string& key, int value) {
|
||||||
data[key] = std::to_string(value);
|
data.insert_or_assign(key, std::to_string(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParamPackage::Set(const std::string& key, float value) {
|
void ParamPackage::Set(const std::string& key, float value) {
|
||||||
data[key] = std::to_string(value);
|
data.insert_or_assign(key, std::to_string(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParamPackage::Has(const std::string& key) const {
|
bool ParamPackage::Has(const std::string& key) const {
|
||||||
|
|
Loading…
Reference in a new issue