diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-02-12 11:44:15 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-02-12 09:08:17 +0000 |
commit | 8d5a8ee53d089cea7543040ecb11d165ab34c506 (patch) | |
tree | 5b1387cb1ce26acf6a341e69c84b24a29c383837 | |
parent | ecca9422c4f8eb20f2d447df51994abc1e1d4e1b (diff) |
QQuickOverlay: use reverse interators for reverse iterations
... instead of indexed access.
Now we have reverse iterator, so we can use it.
Indexed access is less efficient from text size POV.
Also some Intel CPUs (e.g. Skylake) have different
L1 Data Cache Latency:
- 4 cycles for simple access via pointer
- 5 cycles for access with complex address calculation (size_t n, *p; n = p[n]).
See: http://www.7-cpu.com/cpu/Skylake.html
Change-Id: Ic7823def3b96702974840fabf8b4720a914d9d29
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r-- | src/templates/qquickoverlay.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/templates/qquickoverlay.cpp b/src/templates/qquickoverlay.cpp index 388a5960..1b411efe 100644 --- a/src/templates/qquickoverlay.cpp +++ b/src/templates/qquickoverlay.cpp @@ -214,8 +214,8 @@ void QQuickOverlay::mousePressEvent(QMouseEvent *event) event->setAccepted(d->modalPopups > 0); emit pressed(); - for (int i = d->popups.count() - 1; i >= 0; --i) { - if (QQuickPopupPrivate::get(d->popups.at(i))->tryClose(this, event)) + for (auto it = d->popups.rbegin(), end = d->popups.rend(); it != end; ++it) { + if (QQuickPopupPrivate::get(*it)->tryClose(this, event)) break; } } @@ -232,8 +232,8 @@ void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event) event->setAccepted(d->modalPopups > 0); emit released(); - for (int i = d->popups.count() - 1; i >= 0; --i) { - if (QQuickPopupPrivate::get(d->popups.at(i))->tryClose(this, event)) + for (auto it = d->popups.rbegin(), end = d->popups.rend(); it != end; ++it) { + if (QQuickPopupPrivate::get(*it)->tryClose(this, event)) break; } } @@ -258,8 +258,8 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) bool modalBlocked = false; const QQuickItemPrivate *priv = QQuickItemPrivate::get(this); const QList<QQuickItem *> &sortedChildren = priv->paintOrderChildItems(); - for (int i = sortedChildren.count() - 1; i >= 0; --i) { - QQuickItem *popupItem = sortedChildren[i]; + for (auto it = sortedChildren.rbegin(), end = sortedChildren.rend(); it != end; ++it) { + QQuickItem *popupItem = *it; if (popupItem == item) break; |