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

@@ -1094,9 +1094,9 @@ void DocumentManager::checkForReload()
} }
currentStates.insert(fileKey, state); currentStates.insert(fileKey, state);
changeTypes.insert(fileKey, type); changeTypes.insert(fileKey, type);
QList<IDocument *> documents = d->m_states.value(fileKey).lastUpdatedState.keys(); const auto docs = d->m_states.value(fileKey).lastUpdatedState;
for (IDocument *document : documents) for (auto it = docs.begin(); it != docs.end(); ++it)
changedIDocuments.insert(document); changedIDocuments.insert(it.key());
} }
// clean up. do this before we may enter the main loop, otherwise we would // clean up. do this before we may enter the main loop, otherwise we would

View File

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