From 0516487237145ad41b2fd13ecb5f63ba4325c02f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 30 Nov 2015 12:19:31 +0100 Subject: 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 --- src/widgets/itemviews/qdirmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/itemviews/qdirmodel.cpp') diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index daf00e9362..f18233b64c 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -169,8 +169,8 @@ void QDirModelPrivate::invalidate() const QDirNode *current = nodes.pop(); current->stat = false; const QVector &children = current->children; - for (int i = 0; i < children.count(); ++i) - nodes.push(&children.at(i)); + for (const auto &child : children) + nodes.push(&child); } } -- cgit v1.2.3