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)
{
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);
}

View File

@ -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;