mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 19:58:53 +00:00
Common/IniFile: Simplify Set()
We can just utilize map's insert_or_assign() function and check the return value to determine whether or not we need to insert the key into the keys_order vector.
This commit is contained in:
parent
e2c769a9c5
commit
869acb96c6
1 changed files with 4 additions and 7 deletions
|
@ -47,14 +47,11 @@ IniFile::Section::Section(std::string name_) : name{std::move(name_)}
|
||||||
|
|
||||||
void IniFile::Section::Set(const std::string& key, std::string new_value)
|
void IniFile::Section::Set(const std::string& key, std::string new_value)
|
||||||
{
|
{
|
||||||
auto it = values.find(key);
|
const auto result = values.insert_or_assign(key, std::move(new_value));
|
||||||
if (it != values.end())
|
const bool insertion_occurred = result.second;
|
||||||
it->second = std::move(new_value);
|
|
||||||
else
|
if (insertion_occurred)
|
||||||
{
|
|
||||||
values[key] = std::move(new_value);
|
|
||||||
keys_order.push_back(key);
|
keys_order.push_back(key);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::Section::Get(const std::string& key, std::string* value,
|
bool IniFile::Section::Get(const std::string& key, std::string* value,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue