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);
|
metaData.append(d->libraryList.at(i)->metaData);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) {
|
const auto staticPlugins = QPluginLoader::staticPlugins();
|
||||||
|
for (const QStaticPlugin &plugin : staticPlugins) {
|
||||||
const QJsonObject object = plugin.metaData();
|
const QJsonObject object = plugin.metaData();
|
||||||
if (object.value(iidKeyLiteral()) != QLatin1String(d->iid.constData(), d->iid.size()))
|
if (object.value(iidKeyLiteral()) != QLatin1String(d->iid.constData(), d->iid.size()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -406,7 +406,7 @@ inline void QLibraryStore::cleanup()
|
|||||||
|
|
||||||
if (qt_debug_component()) {
|
if (qt_debug_component()) {
|
||||||
// dump all objects that remain
|
// dump all objects that remain
|
||||||
foreach (QLibraryPrivate *lib, data->libraryMap) {
|
for (QLibraryPrivate *lib : qAsConst(data->libraryMap)) {
|
||||||
if (lib)
|
if (lib)
|
||||||
qDebug() << "On QtCore unload," << lib->fileName << "was leaked, with"
|
qDebug() << "On QtCore unload," << lib->fileName << "was leaked, with"
|
||||||
<< lib->libraryRefCount.load() << "users";
|
<< lib->libraryRefCount.load() << "users";
|
||||||
|
@ -104,7 +104,7 @@ bool QLibraryPrivate::load_sys()
|
|||||||
attempts.prepend(QDir::rootPath() + fileName);
|
attempts.prepend(QDir::rootPath() + fileName);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Q_FOREACH (const QString &attempt, attempts) {
|
for (const QString &attempt : qAsConst(attempts)) {
|
||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
|
pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
|
||||||
#else // Q_OS_WINRT
|
#else // Q_OS_WINRT
|
||||||
|
@ -300,9 +300,9 @@ static QString locatePlugin(const QString& fileName)
|
|||||||
paths.prepend(QStringLiteral(".")); // search in current dir first
|
paths.prepend(QStringLiteral(".")); // search in current dir first
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &path, paths) {
|
for (const QString &path : qAsConst(paths)) {
|
||||||
foreach (const QString &prefix, prefixes) {
|
for (const QString &prefix : qAsConst(prefixes)) {
|
||||||
foreach (const QString &suffix, suffixes) {
|
for (const QString &suffix : qAsConst(suffixes)) {
|
||||||
const QString fn = path + QLatin1Char('/') + basePath + prefix + baseName + suffix;
|
const QString fn = path + QLatin1Char('/') + basePath + prefix + baseName + suffix;
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "Trying..." << fn;
|
qDebug() << "Trying..." << fn;
|
||||||
|
@ -263,7 +263,7 @@ void QThreadPoolPrivate::reset()
|
|||||||
allThreadsCopy.swap(allThreads);
|
allThreadsCopy.swap(allThreads);
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
|
|
||||||
foreach (QThreadPoolThread *thread, allThreadsCopy) {
|
for (QThreadPoolThread *thread : qAsConst(allThreadsCopy)) {
|
||||||
thread->runnableReady.wakeAll();
|
thread->runnableReady.wakeAll();
|
||||||
thread->wait();
|
thread->wait();
|
||||||
delete thread;
|
delete thread;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user