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:
@@ -1301,9 +1301,8 @@ void CMakeBuildSystem::runCTest()
|
||||
std::function<QJsonObject(int)> findAncestor = [&](int index){
|
||||
const QJsonObject node = nodes.at(index).toObject();
|
||||
const int parent = node.value("parent").toInt(-1);
|
||||
if (seen.contains(parent) || parent < 0)
|
||||
if (parent < 0 || !Utils::insert(seen, parent))
|
||||
return node;
|
||||
seen << parent;
|
||||
return findAncestor(parent);
|
||||
};
|
||||
const QJsonObject btRef = findAncestor(bt);
|
||||
|
||||
Reference in New Issue
Block a user