summaryrefslogtreecommitdiffstats
path: root/src/OverridesSettingsRepository.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-04-14 11:58:31 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-04-14 11:58:31 +0200
commit5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2 (patch)
tree53931e6b54099e102786612400ef3a75375b2b04 /src/OverridesSettingsRepository.cpp
parentMerge pull request #3139 from LogicParrot/freezeFix (diff)
parentRevert "Issue3136" (diff)
downloadcuberite-5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2.tar
cuberite-5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2.tar.gz
cuberite-5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2.tar.bz2
cuberite-5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2.tar.lz
cuberite-5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2.tar.xz
cuberite-5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2.tar.zst
cuberite-5231e4a7e4cf0cad4d7e06ccd8ed7b6d186ad1f2.zip
Diffstat (limited to 'src/OverridesSettingsRepository.cpp')
-rw-r--r--src/OverridesSettingsRepository.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/OverridesSettingsRepository.cpp b/src/OverridesSettingsRepository.cpp
index f3db96a5c..9e85abce6 100644
--- a/src/OverridesSettingsRepository.cpp
+++ b/src/OverridesSettingsRepository.cpp
@@ -108,26 +108,31 @@ std::vector<std::pair<AString, AString>> cOverridesSettingsRepository::GetValues
{
auto overrides = m_Overrides->GetValues(a_keyName);
auto main = m_Main->GetValues(a_keyName);
+ std::sort(overrides.begin(), overrides.end(), [](std::pair<AString, AString> a, std::pair<AString, AString> b) -> bool { return a < b ;});
+ std::sort(main.begin(), main.end(), [](std::pair<AString, AString> a, std::pair<AString, AString> b) -> bool { return a < b ;});
- auto ret = overrides;
+ std::vector<std::pair<AString, AString>> ret;
- for (const auto & mainpair : main)
+
+ size_t overridesIndex = 0;
+ for (auto pair : main)
{
- bool found = false;
- for (const auto & returnpair : ret)
+ if (overridesIndex >= overrides.size())
+ {
+ ret.push_back(pair);
+ continue;
+ }
+ if (pair.first == overrides[overridesIndex].first)
{
- if (returnpair.first == mainpair.first)
- {
- found = true;
- break;
- }
+ continue;
}
- if (found == false)
+ while (pair.first > overrides[overridesIndex].first)
{
- ret.push_back(mainpair);
+ ret.push_back(overrides[overridesIndex]);
+ overridesIndex++;
}
+ ret.push_back(pair);
}
-
return ret;
}
@@ -265,3 +270,4 @@ bool cOverridesSettingsRepository::Flush()
{
return m_Overrides->Flush() && m_Main->Flush();
}
+