From 25fff849e8f34af6d41ff36f2891bb4099b89360 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 11 Jul 2021 19:28:35 +0200 Subject: QDirIterator: add nextFileInfo() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this change, next() was the only way to advance the iterator, whether the caller was ultimately interested in just the filePath() (good) or not (bad luck, had to call .fileInfo()). Add a new function, nextFileInfo(), with returns fileInfo() instead. Incidentally, the returned object has already been constructed as part of advance()ing the iterator, so the new function is faster than next() even if the result is ignored, because we're not calculating a QString result the caller may not be interested in. Use the new function around the code. Fix a couple of cases of next(); fileInfo().filePath() (just use next()'s return value) as a drive-by. [ChangeLog][QtCore][QDirIterator] Added nextFileInfo(), which is like next(), but returns fileInfo() instead of filePath(). Change-Id: I601220575961169b44139fc55b9eae6c3197afb4 Reviewed-by: MÃ¥rten Nordheim --- src/gui/itemmodels/qfileinfogatherer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gui/itemmodels') diff --git a/src/gui/itemmodels/qfileinfogatherer.cpp b/src/gui/itemmodels/qfileinfogatherer.cpp index bd368e945c..ec4ae2269b 100644 --- a/src/gui/itemmodels/qfileinfogatherer.cpp +++ b/src/gui/itemmodels/qfileinfogatherer.cpp @@ -401,8 +401,7 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil if (files.isEmpty()) { QDirIterator dirIt(path, QDir::AllEntries | QDir::System | QDir::Hidden); while (!abort.loadRelaxed() && dirIt.hasNext()) { - dirIt.next(); - fileInfo = dirIt.fileInfo(); + fileInfo = dirIt.nextFileInfo(); fileInfo.stat(); allFiles.append(fileInfo.fileName()); fetch(fileInfo, base, firstTime, updatedFiles, path); -- cgit v1.2.3