diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-01-26 14:38:54 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-28 10:50:18 +0000 |
commit | 85c2a128ef8d1b5fbddf551691bccc0770e558ba (patch) | |
tree | 99580041fa8c0e60d2e91451d1a7531055803d3d /src/widgets/kernel/qwidget.cpp | |
parent | e1c2bfa53b7549a1283f5b52974ea90b6a2b4659 (diff) |
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) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index de832d667d..ec5a68eeef 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1417,7 +1417,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win = topData()->window; } - foreach (const QByteArray &propertyName, q->dynamicPropertyNames()) { + const auto dynamicPropertyNames = q->dynamicPropertyNames(); + for (const QByteArray &propertyName : dynamicPropertyNames) { if (!qstrncmp(propertyName, "_q_platform_", 12)) win->setProperty(propertyName, q->property(propertyName)); } @@ -11984,7 +11985,9 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) QWidget *targetWidget = 0; int shortestDistance = INT_MAX; - foreach(QWidget *targetCandidate, QApplication::allWidgets()) { + + const auto targetCandidates = QApplication::allWidgets(); + for (QWidget *targetCandidate : targetCandidates) { const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint())); |