diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2019-05-23 12:15:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-23 12:15:30 +0200 |
| commit | 617747e9057c3fc5a34ae19e7c963ef6116e228d (patch) | |
| tree | dedc341c2a80284bae0121bc2ec791a99db62b0c /Source/Core/Common/IniFile.cpp | |
| parent | 67c2aa070152ce8f09feebc5a5fb23695281f055 (diff) | |
| parent | 869acb96c6416f11a53670652ae8802907022f58 (diff) | |
Merge pull request #8113 from lioncash/ini-key
Common/IniFile: Simplify Set()
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 c0e07df483..d059e3dd1b 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, |
