diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-07 11:44:36 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-07 11:48:51 +0200 |
commit | 93827875d4515a686978d98ff239332ce1adcb01 (patch) | |
tree | 227afd3b8a402f86cd0b9ba25ae454fe9114a248 /src | |
parent | 1063f6ee4ca23ac30495e354532b9ab72fef7737 (diff) |
FaviconManager: fix quadratic loop
QMutableListIterator::remove() is linear, so calling it in a loop
constitutes quadratic behavior. Use std::remove_if, which is linear.
Change-Id: I238b051fe87e348e5576452a6581b8799bfb49b5
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/favicon_manager.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp index 489e23d99..a06da6769 100644 --- a/src/core/favicon_manager.cpp +++ b/src/core/favicon_manager.cpp @@ -229,11 +229,10 @@ QList<FaviconInfo> FaviconManager::getFaviconInfoList(bool candidatesOnly) const QList<FaviconInfo> faviconInfoList = m_faviconInfoMap.values(); if (candidatesOnly) { - QMutableListIterator<FaviconInfo> it(faviconInfoList); - while (it.hasNext()) { - if (!it.next().candidate) - it.remove(); - } + const auto hasNoCandidate = [](const FaviconInfo &info) { return !info.candidate; }; + faviconInfoList.erase(std::remove_if(faviconInfoList.begin(), faviconInfoList.end(), + hasNoCandidate), + faviconInfoList.end()); } return faviconInfoList; |