Fix occurrences of the contains/insert anti-pattern

Introduce and make use of Utils::insert() for QSet with a return value
that indicates whether insertion actually happened.

Change-Id: I655e4bc3553b74fea5ae8956205e4d8070118d63
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Christian Kandeler
2023-06-22 14:58:11 +02:00
parent ae33199d04
commit cf6bd7e012
39 changed files with 107 additions and 169 deletions

View File

@@ -774,10 +774,8 @@ QSet<FilePath> Snapshot::allIncludesForDocument(const FilePath &filePath) const
if (Document::Ptr doc = document(file)) {
const FilePaths includedFiles = doc->includedFiles(Document::Duplicates::Keep);
for (const FilePath &inc : includedFiles) {
if (!result.contains(inc)) {
result.insert(inc);
if (Utils::insert(result, inc))
files.push(inc);
}
}
}
}