diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-03-04 15:02:36 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-03-09 09:57:28 +0000 |
commit | 9dcbffabbdb2da59c2f9a1227df2d6d66866d654 (patch) | |
tree | 969121dd9afc50ac9d3427e6ffaf154b5a5b9826 /src | |
parent | 27a2a0255946ddcd83cf28fa778685092e56e98d (diff) |
CoreLib: replace Java-style iterators
... with STL-style iterators or with algorithms.
Java-style iterators have overhead.
Change-Id: Ibeace7357c205a39dff3ca3fc0c835a026a15cac
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/mimetypes/qmimeglobpattern.cpp | 6 | ||||
-rw-r--r-- | src/corelib/mimetypes/qmimeglobpattern_p.h | 9 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp index 5205595943..94be5385f3 100644 --- a/src/corelib/mimetypes/qmimeglobpattern.cpp +++ b/src/corelib/mimetypes/qmimeglobpattern.cpp @@ -182,10 +182,8 @@ void QMimeAllGlobPatterns::addGlob(const QMimeGlobPattern &glob) void QMimeAllGlobPatterns::removeMimeType(const QString &mimeType) { - QMutableHashIterator<QString, QStringList> it(m_fastPatterns); - while (it.hasNext()) { - it.next().value().removeAll(mimeType); - } + for (auto &x : m_fastPatterns) + x.removeAll(mimeType); m_highWeightGlobs.removeMimeType(mimeType); m_lowWeightGlobs.removeMimeType(mimeType); } diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h index 7b4ecd2f6a..e4c74ff7fa 100644 --- a/src/corelib/mimetypes/qmimeglobpattern_p.h +++ b/src/corelib/mimetypes/qmimeglobpattern_p.h @@ -130,11 +130,10 @@ public: */ void removeMimeType(const QString &mimeType) { - QMutableListIterator<QMimeGlobPattern> it(*this); - while (it.hasNext()) { - if (it.next().mimeType() == mimeType) - it.remove(); - } + auto isMimeTypeEqual = [&mimeType](const QMimeGlobPattern &pattern) { + return pattern.mimeType() == mimeType; + }; + erase(std::remove_if(begin(), end(), isMimeTypeEqual), end()); } void match(QMimeGlobMatchResult &result, const QString &fileName) const; |