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:
@@ -10,6 +10,7 @@
|
||||
#include "testtreemodel.h"
|
||||
|
||||
#include <projectexplorer/projectexplorericons.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QFontMetrics>
|
||||
@@ -202,10 +203,7 @@ bool TestResultItem::updateDescendantTypes(ResultType t)
|
||||
if (t == ResultType::TestStart || t == ResultType::TestEnd) // these are special
|
||||
return false;
|
||||
|
||||
if (m_descendantsTypes.contains(t))
|
||||
return false;
|
||||
m_descendantsTypes.insert(t);
|
||||
return true;
|
||||
return Utils::insert(m_descendantsTypes, t);
|
||||
}
|
||||
|
||||
bool TestResultItem::descendantTypesContainsAnyOf(const QSet<ResultType> &types) const
|
||||
@@ -467,8 +465,7 @@ void TestResultFilterModel::enableAllResultTypes(bool enabled)
|
||||
|
||||
void TestResultFilterModel::toggleTestResultType(ResultType type)
|
||||
{
|
||||
if (m_enabled.contains(type)) {
|
||||
m_enabled.remove(type);
|
||||
if (m_enabled.remove(type)) {
|
||||
if (type == ResultType::MessageInternal)
|
||||
m_enabled.remove(ResultType::TestEnd);
|
||||
if (type == ResultType::MessageDebug)
|
||||
|
||||
Reference in New Issue
Block a user