forked from qt-creator/qt-creator
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:
@@ -952,9 +952,8 @@ QList<FindReferences::Usage> FindReferences::findUsageOfType(const Utils::FilePa
|
||||
QSet<Utils::FilePath> docDone;
|
||||
for (const QmlJS::Document::Ptr &doc : std::as_const(snapshot)) {
|
||||
Utils::FilePath sourceFile = modelManager->fileToSource(doc->fileName());
|
||||
if (docDone.contains(sourceFile))
|
||||
if (!Utils::insert(docDone, sourceFile))
|
||||
continue;
|
||||
docDone.insert(sourceFile);
|
||||
QmlJS::Document::Ptr sourceDoc = doc;
|
||||
if (sourceFile != doc->fileName())
|
||||
sourceDoc = snapshot.document(sourceFile);
|
||||
|
||||
Reference in New Issue
Block a user