From 85c2a128ef8d1b5fbddf551691bccc0770e558ba Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 26 Jan 2016 14:38:54 +0100 Subject: QtWidgets: eradicate Q_FOREACH loops [rvalues] ... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Saves 2.2KiB in test size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I914aa20fe65577b2e32ea7ea89d51a8d003a57ba Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qdialogbuttonbox.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets/widgets/qdialogbuttonbox.cpp') diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 6fc8cb5e26..2b68c308ec 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -964,7 +964,8 @@ bool QDialogButtonBox::event(QEvent *event) break; } - foreach (QPushButton *pb, (dialog ? dialog : this)->findChildren()) { + const auto pbs = (dialog ? dialog : this)->findChildren(); + for (QPushButton *pb : pbs) { if (pb->isDefault() && pb != firstAcceptButton) { hasDefault = true; break; -- cgit v1.2.3