From 73baf55b107350211e53bdf839a6ba2d273865bd Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Tue, 23 Aug 2016 11:33:30 +0300 Subject: Replace 'foreach' with 'range for' And add QT_NO_FOREACH define to .qmake.conf. Now QuickControls2 is 'foreach' free. Change-Id: I98695258859decadae6fd2f23f5f6f5ef2b0550f Reviewed-by: J-P Nurmi --- tests/benchmarks/creationtime/tst_creationtime.cpp | 7 ++++--- tests/benchmarks/objectcount/tst_objectcount.cpp | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'tests/benchmarks') diff --git a/tests/benchmarks/creationtime/tst_creationtime.cpp b/tests/benchmarks/creationtime/tst_creationtime.cpp index 877cf273..3eec3825 100644 --- a/tests/benchmarks/creationtime/tst_creationtime.cpp +++ b/tests/benchmarks/creationtime/tst_creationtime.cpp @@ -78,11 +78,12 @@ static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QSt // the engine's import path. This way we can use QQmlComponent to load each QML file // for benchmarking. - QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + sourcePath).entryInfoList(QStringList("*.qml"), QDir::Files); - foreach (const QFileInfo &entry, entries) { + const QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + sourcePath).entryInfoList(QStringList("*.qml"), QDir::Files); + for (const QFileInfo &entry : entries) { QString name = entry.baseName(); if (!skiplist.contains(name)) { - foreach (const QString &importPath, engine->importPathList()) { + const auto importPathList = engine->importPathList(); + for (const QString &importPath : importPathList) { QString name = entry.dir().dirName() + "/" + entry.fileName(); QString filePath = importPath + "/" + targetPath + "/" + entry.fileName(); if (QFile::exists(filePath)) { diff --git a/tests/benchmarks/objectcount/tst_objectcount.cpp b/tests/benchmarks/objectcount/tst_objectcount.cpp index 554b8af1..549d7eef 100644 --- a/tests/benchmarks/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/objectcount/tst_objectcount.cpp @@ -100,7 +100,7 @@ static void printItems(const QList &items) std::cout << " QQuickItems: " << items.count() << " (total of QObjects: " << qt_qobjects->count() << ")" << std::endl; if (qt_verbose) { - foreach (QObject *object, *qt_qobjects) + for (QObject *object : qAsConst(*qt_qobjects)) qInfo() << "\t" << object; } } @@ -118,11 +118,12 @@ static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QSt // the engine's import path. This way we can use QQmlComponent to load each QML file // for benchmarking. - QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + sourcePath).entryInfoList(QStringList("*.qml"), QDir::Files); - foreach (const QFileInfo &entry, entries) { + const QFileInfoList entries = QDir(QQC2_IMPORT_PATH "/" + sourcePath).entryInfoList(QStringList("*.qml"), QDir::Files); + for (const QFileInfo &entry : entries) { QString name = entry.baseName(); if (!skiplist.contains(name)) { - foreach (const QString &importPath, engine->importPathList()) { + const auto importPathList = engine->importPathList(); + for (const QString &importPath : importPathList) { QString name = entry.dir().dirName() + "/" + entry.fileName(); QString filePath = importPath + "/" + targetPath + "/" + entry.fileName(); if (QFile::exists(filePath)) { @@ -148,7 +149,7 @@ static void doBenchmark(QQmlEngine *engine, const QUrl &url) QVERIFY2(object.data(), qPrintable(component.errorString())); QList items; - foreach (QObject *object, *qt_qobjects()) { + for (QObject *object : qAsConst(*qt_qobjects)) { QQuickItem *item = qobject_cast(object); if (item) items += item; -- cgit v1.2.3