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:
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <debugger/analyzer/diagnosticlocation.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fsengine/fileiconprovider.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
@@ -99,12 +100,10 @@ void DiagnosticsModel::clear()
|
||||
|
||||
void DiagnosticsModel::add(const Diagnostic &diagnostic)
|
||||
{
|
||||
if (m_diagnostics.contains(diagnostic))
|
||||
if (!Utils::insert(m_diagnostics, diagnostic))
|
||||
return;
|
||||
|
||||
const auto hasData = !m_diagnostics.isEmpty();
|
||||
m_diagnostics.insert(diagnostic);
|
||||
if (!hasData)
|
||||
if (m_diagnostics.size() == 1)
|
||||
emit hasDataChanged(true);
|
||||
|
||||
const QString filePath = diagnostic.fileName.toString();
|
||||
|
||||
Reference in New Issue
Block a user