QFactoryLoader: use QDirIterator instead of QDir

This showed up on a benchmark when the number of files in the directory
was way too big.

Change-Id: I5e52dc5b093c43a3b678fffd16b5ef9a938abc63
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Thiago Macieira 2021-11-09 09:04:46 -08:00 committed by Edward Welbourne
parent 664c56d6b1
commit d5cac0b19b

View File

@ -51,7 +51,7 @@
#include "qcbormap.h"
#include "qcborvalue.h"
#include "qcborvalue.h"
#include "qdir.h"
#include "qdiriterator.h"
#include "qfileinfo.h"
#include "qjsonarray.h"
#include "qjsondocument.h"
@ -170,7 +170,7 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
qCDebug(lcFactoryLoader) << "checking directory path" << path << "...";
QStringList plugins = QDir(path).entryList(
QDirIterator plugins(path,
#if defined(Q_OS_WIN)
QStringList(QStringLiteral("*.dll")),
#elif defined(Q_OS_ANDROID)
@ -178,8 +178,8 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
#endif
QDir::Files);
for (int j = 0; j < plugins.count(); ++j) {
QString fileName = QDir::cleanPath(path + QLatin1Char('/') + plugins.at(j));
while (plugins.hasNext()) {
QString fileName = plugins.next();
#ifdef Q_OS_MAC
const bool isDebugPlugin = fileName.endsWith(QLatin1String("_debug.dylib"));
const bool isDebugLibrary =