mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-02 11:11:34 +00:00
Optimize value deduping in Qt openmw.cfg parsing
This commit is contained in:
parent
1c242425b0
commit
de158a476c
1 changed files with 8 additions and 11 deletions
|
@ -189,19 +189,16 @@ bool Config::GameSettings::readFile(
|
|||
if (ignoreContent && (key == QLatin1String("content") || key == QLatin1String("data")))
|
||||
continue;
|
||||
|
||||
QList<SettingValue> values = cache.values(key);
|
||||
values.append(settings.values(key));
|
||||
|
||||
bool exists = false;
|
||||
for (const auto& existingValue : values)
|
||||
{
|
||||
if (existingValue.value == value.value)
|
||||
auto containsValue = [&](const QMultiMap<QString, SettingValue>& map) {
|
||||
for (auto [itr, end] = map.equal_range(key); itr != end; ++itr)
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
if (itr->value == value.value)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!exists)
|
||||
return false;
|
||||
};
|
||||
|
||||
if (!containsValue(cache) && !containsValue(settings))
|
||||
{
|
||||
cache.insert(key, value);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue