summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-12-23 00:15:30 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-01-04 12:22:34 +0000
commit8faf51429e243a3e009f66a5f58321da259b9fc6 (patch)
treeddc61642266864b610bc8f8d38d4025fcc15eadc /src
parent0ff221f5229b2ca09a63c73b724348585934d7dd (diff)
QtCore: eradicate all Q_FOREACH loops [threads, plugins]
Saves just shy of 4KiB in text size on optimized GCC 4.9 Linux AMD64 builds, iow: ~0.07% of the total QtCore library size. Change-Id: I87fdcc8ee25c6bb5dabddb9a694ab4496b1538fa Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp3
-rw-r--r--src/corelib/plugin/qlibrary.cpp2
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp2
-rw-r--r--src/corelib/plugin/qpluginloader.cpp6
-rw-r--r--src/corelib/thread/qthreadpool.cpp2
5 files changed, 8 insertions, 7 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 7556f5caf8..78f540cf56 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -265,7 +265,8 @@ QList<QJsonObject> QFactoryLoader::metaData() const
metaData.append(d->libraryList.at(i)->metaData);
#endif
- foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) {
+ const auto staticPlugins = QPluginLoader::staticPlugins();
+ for (const QStaticPlugin &plugin : staticPlugins) {
const QJsonObject object = plugin.metaData();
if (object.value(iidKeyLiteral()) != QLatin1String(d->iid.constData(), d->iid.size()))
continue;
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 38e82fc059..45859e058e 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -406,7 +406,7 @@ inline void QLibraryStore::cleanup()
if (qt_debug_component()) {
// dump all objects that remain
- foreach (QLibraryPrivate *lib, data->libraryMap) {
+ for (QLibraryPrivate *lib : qAsConst(data->libraryMap)) {
if (lib)
qDebug() << "On QtCore unload," << lib->fileName << "was leaked, with"
<< lib->libraryRefCount.load() << "users";
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index f5604a24bd..47a220bf69 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -104,7 +104,7 @@ bool QLibraryPrivate::load_sys()
attempts.prepend(QDir::rootPath() + fileName);
#endif
- Q_FOREACH (const QString &attempt, attempts) {
+ for (const QString &attempt : qAsConst(attempts)) {
#ifndef Q_OS_WINRT
pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
#else // Q_OS_WINRT
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 8264a27842..af6e3e0e93 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -300,9 +300,9 @@ static QString locatePlugin(const QString& fileName)
paths.prepend(QStringLiteral(".")); // search in current dir first
}
- foreach (const QString &path, paths) {
- foreach (const QString &prefix, prefixes) {
- foreach (const QString &suffix, suffixes) {
+ for (const QString &path : qAsConst(paths)) {
+ for (const QString &prefix : qAsConst(prefixes)) {
+ for (const QString &suffix : qAsConst(suffixes)) {
const QString fn = path + QLatin1Char('/') + basePath + prefix + baseName + suffix;
if (debug)
qDebug() << "Trying..." << fn;
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index b6b3be8d92..c23e7ace15 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -263,7 +263,7 @@ void QThreadPoolPrivate::reset()
allThreadsCopy.swap(allThreads);
locker.unlock();
- foreach (QThreadPoolThread *thread, allThreadsCopy) {
+ for (QThreadPoolThread *thread : qAsConst(allThreadsCopy)) {
thread->runnableReady.wakeAll();
thread->wait();
delete thread;