path: root/src/widgets/dialogs/qfileinfogatherer.cpp
diff options
authorMarc Mutz <>2015-11-30 12:19:31 +0100
committerMarc Mutz <>2015-12-16 17:41:50 +0000
commit0516487237145ad41b2fd13ecb5f63ba4325c02f (patch)
tree8dbc353c28857742882610cc5d810c8c64052f0f /src/widgets/dialogs/qfileinfogatherer.cpp
parentb69751863472b186aaad08db6b9b08de81e95dc4 (diff)
QtWidgets: replace some index-based for loops with C++11 range-for
This needs to be handled a bit carefully, because Qt containers will detach upon being iteratoed over using range-for. In the cases of this patch, that cannot happen, because all containers are marked as const (either by this patch or before). Separate patches will deal with other situations. Apart from being more readable, range-for loops are also the most efficient for loop. This patch shaves almost 2K of text size off an optimized Linux AMD64 GCC 4.9 build. Change-Id: I53810c7b25420b4fd449d20c90c07503c5e76a66 Reviewed-by: Edward Welbourne <> Reviewed-by: Lars Knoll <>
Diffstat (limited to 'src/widgets/dialogs/qfileinfogatherer.cpp')
1 files changed, 2 insertions, 2 deletions
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index 92d6b8f3be..d99e3df802 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -282,8 +282,8 @@ void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &fil
infoList = QDir::drives();
} else {
- for (int i = 0; i < files.count(); ++i)
- infoList << QFileInfo(;
+ for (const auto &file : files)
+ infoList << QFileInfo(file);
for (int i = infoList.count() - 1; i >= 0; --i) {
QString driveName = translateDriveName(;