From de158a476c3d9b8fc395a06ba799b5f6655d5f42 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 6 Jun 2025 16:27:52 +0300 Subject: [PATCH] Optimize value deduping in Qt openmw.cfg parsing --- components/config/gamesettings.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index b70fe2db4b..7f022bb653 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -189,19 +189,16 @@ bool Config::GameSettings::readFile( if (ignoreContent && (key == QLatin1String("content") || key == QLatin1String("data"))) continue; - QList 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& 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); }