CorePlugin: Avoid using keys()

Instead, iterate directly over the container.

Change-Id: I508126a6afc8f4354bc7810e09f57866d1d1d2ab
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2024-01-08 23:47:36 +01:00
parent 1e7970ff0b
commit 6c8ef7153c
2 changed files with 9 additions and 8 deletions

View File

@@ -209,14 +209,15 @@ void remove(const QString &key)
const QString effectiveKey = d->effectiveKey(key);
// Remove keys from the cache
const QStringList keys = d->m_settings.keys();
for (const QString &k : keys) {
for (auto it = d->m_settings.cbegin(); it != d->m_settings.cend(); ) {
// Either it's an exact match, or it matches up to a /
const QString k = it.key();
if (k.startsWith(effectiveKey)
&& (k.length() == effectiveKey.length()
|| k.at(effectiveKey.length()) == QLatin1Char('/')))
{
d->m_settings.remove(k);
|| k.at(effectiveKey.length()) == QLatin1Char('/'))) {
it = d->m_settings.erase(it);
} else {
++it;
}
}