From ee9ab8d3933cd4b192549c5b2c2135ac937124ac Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 15 Jan 2023 18:33:15 +0400 Subject: [PATCH] Use STL-style iterators instead of Java-style ones --- components/config/gamesettings.cpp | 16 ++++++---------- components/config/launchersettings.cpp | 8 +++----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/components/config/gamesettings.cpp b/components/config/gamesettings.cpp index c28edf1e93..bc2286fbfd 100644 --- a/components/config/gamesettings.cpp +++ b/components/config/gamesettings.cpp @@ -165,12 +165,10 @@ bool Config::GameSettings::readFile(QTextStream& stream, QMultiMap i(mUserSettings); - i.toBack(); - - while (i.hasPrevious()) + auto i = mUserSettings.end(); + while (i != mUserSettings.begin()) { - i.previous(); + i--; // path lines (e.g. 'data=...') need quotes and ampersands escaping to match how boost::filesystem::path uses // boost::io::quoted @@ -388,12 +386,10 @@ bool Config::GameSettings::writeFileWithComments(QFile& file) // Iterate in reverse order to preserve insertion order QString settingLine; - QMapIterator it(mUserSettings); - it.toBack(); - - while (it.hasPrevious()) + auto it = mUserSettings.end(); + while (it != mUserSettings.begin()) { - it.previous(); + it--; if (it.key() == QLatin1String("data") || it.key() == QLatin1String("data-local") || it.key() == QLatin1String("resources") || it.key() == QLatin1String("load-savegame")) diff --git a/components/config/launchersettings.cpp b/components/config/launchersettings.cpp index 0cea8270aa..02a5202857 100644 --- a/components/config/launchersettings.cpp +++ b/components/config/launchersettings.cpp @@ -50,12 +50,10 @@ bool Config::LauncherSettings::writeFile(QTextStream& stream) QRegularExpression sectionRe("^([^/]+)/(.+)$"); QMultiMap settings = SettingsBase::getSettings(); - QMapIterator i(settings); - i.toBack(); - - while (i.hasPrevious()) + auto i = settings.end(); + while (i != settings.begin()) { - i.previous(); + i--; QString prefix; QString key;