Replace backwards Java-style iteration with new reverse_iterators

Faster, and, thanks to the new reverse_iterators, just as convenient.

Change-Id: Ibc6c64051a8ede4a47428e9271ffbeaa921fc255
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Marc Mutz 2015-10-17 23:22:29 +02:00
parent 80d7b19b80
commit f9de9eae3a
2 changed files with 5 additions and 9 deletions

View File

@ -578,11 +578,8 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
QString mainPattern;
const QString preferredLanguage = QLocale::system().name();
QListIterator<QString> mimeFilesIter(mimeFiles);
mimeFilesIter.toBack();
while (mimeFilesIter.hasPrevious()) { // global first, then local.
const QString fullPath = mimeFilesIter.previous();
QFile qfile(fullPath);
for (QStringList::const_reverse_iterator it = mimeFiles.crbegin(), end = mimeFiles.crend(); it != end; ++it) { // global first, then local.
QFile qfile(*it);
if (!qfile.open(QFile::ReadOnly))
continue;

View File

@ -192,11 +192,10 @@ void QMenuPrivate::syncPlatformMenu()
return;
QPlatformMenuItem *beforeItem = Q_NULLPTR;
QListIterator<QAction*> it(q->actions());
it.toBack();
while (it.hasPrevious()) {
const QList<QAction*> actions = q->actions();
for (QList<QAction*>::const_reverse_iterator it = actions.rbegin(), end = actions.rend(); it != end; ++it) {
QPlatformMenuItem *menuItem = platformMenu->createMenuItem();
QAction *action = it.previous();
QAction *action = *it;
menuItem->setTag(reinterpret_cast<quintptr>(action));
QObject::connect(menuItem, SIGNAL(activated()), action, SLOT(trigger()), Qt::QueuedConnection);
QObject::connect(menuItem, SIGNAL(hovered()), action, SIGNAL(hovered()), Qt::QueuedConnection);