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>
This commit is contained in:
Anton Kudryavtsev 2016-03-04 15:02:36 +03:00
parent 27a2a02559
commit 9dcbffabbd
2 changed files with 6 additions and 9 deletions

View File

@ -182,10 +182,8 @@ void QMimeAllGlobPatterns::addGlob(const QMimeGlobPattern &glob)
void QMimeAllGlobPatterns::removeMimeType(const QString &mimeType) void QMimeAllGlobPatterns::removeMimeType(const QString &mimeType)
{ {
QMutableHashIterator<QString, QStringList> it(m_fastPatterns); for (auto &x : m_fastPatterns)
while (it.hasNext()) { x.removeAll(mimeType);
it.next().value().removeAll(mimeType);
}
m_highWeightGlobs.removeMimeType(mimeType); m_highWeightGlobs.removeMimeType(mimeType);
m_lowWeightGlobs.removeMimeType(mimeType); m_lowWeightGlobs.removeMimeType(mimeType);
} }

View File

@ -130,11 +130,10 @@ public:
*/ */
void removeMimeType(const QString &mimeType) void removeMimeType(const QString &mimeType)
{ {
QMutableListIterator<QMimeGlobPattern> it(*this); auto isMimeTypeEqual = [&mimeType](const QMimeGlobPattern &pattern) {
while (it.hasNext()) { return pattern.mimeType() == mimeType;
if (it.next().mimeType() == mimeType) };
it.remove(); erase(std::remove_if(begin(), end(), isMimeTypeEqual), end());
}
} }
void match(QMimeGlobMatchResult &result, const QString &fileName) const; void match(QMimeGlobMatchResult &result, const QString &fileName) const;