diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-05-22 20:58:47 -0400 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-05-22 20:58:49 -0400 |
| commit | 869acb96c6416f11a53670652ae8802907022f58 (patch) | |
| tree | fe33bd34addcf818acc55d6c2bfb31818f5d69d5 /Source/Core/Common/IniFile.cpp | |
| parent | e2c769a9c5afa9171f45d36ee39a0c176f24ee13 (diff) | |
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.
Diffstat (limited to 'Source/Core/Common/IniFile.cpp')
| -rw-r--r-- | Source/Core/Common/IniFile.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index 43bbe7b50b..189756a83a 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -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) { - auto it = values.find(key); - if (it != values.end()) - it->second = std::move(new_value); - else - { - values[key] = std::move(new_value); + const auto result = values.insert_or_assign(key, std::move(new_value)); + const bool insertion_occurred = result.second; + + if (insertion_occurred) keys_order.push_back(key); - } } bool IniFile::Section::Get(const std::string& key, std::string* value, |
