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>
This commit is contained in:
parent
0ff221f522
commit
8faf51429e
@ -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;
|
||||
|
@ -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";
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user