diff options
| author | Christian Kandeler <[email protected]> | 2023-06-22 14:58:11 +0200 |
|---|---|---|
| committer | Christian Kandeler <[email protected]> | 2023-06-23 09:51:54 +0000 |
| commit | cf6bd7e0124f31374f3a4abd05d14199d201961b (patch) | |
| tree | 90ce2081bdea0b7bece256bd00c0d0476171e00f /src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp | |
| parent | ae33199d046902bb9877810df2dbc590b083ef3c (diff) | |
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 <[email protected]>
Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp')
| -rw-r--r-- | src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp b/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp index a2f87b8cd8b..e2bc8434fb6 100644 --- a/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp +++ b/src/plugins/cppcheck/cppcheckdiagnosticsmodel.cpp @@ -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(); |
