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:
@@ -6,7 +6,6 @@
|
||||
#include "LookupContext.h"
|
||||
#include "Overview.h"
|
||||
#include "DeprecatedGenTemplateInstance.h"
|
||||
#include "CppRewriter.h"
|
||||
#include "TypeOfExpression.h"
|
||||
|
||||
#include <cplusplus/Control.h>
|
||||
@@ -20,6 +19,8 @@
|
||||
#include <cplusplus/NameVisitor.h>
|
||||
#include <cplusplus/Templates.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
#include <QSet>
|
||||
@@ -142,9 +143,8 @@ private:
|
||||
for (const LookupItem &it : namedTypeItems) {
|
||||
Symbol *declaration = it.declaration();
|
||||
if (declaration && declaration->isTypedef()) {
|
||||
if (visited.contains(declaration))
|
||||
if (!Utils::insert(visited, declaration))
|
||||
break;
|
||||
visited.insert(declaration);
|
||||
|
||||
// continue working with the typedefed type and scope
|
||||
if (type->type()->asPointerType()) {
|
||||
|
||||
Reference in New Issue
Block a user