summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-06-21 12:37:37 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-06-21 11:44:31 +0000
commit3045ac99f296b866b25df318f13726d8f64494e8 (patch)
tree2fcfd26e1af4768e97a6c1b532f4b8f67d9df7b9 /src
parent8a25f888e947d406f69759b51732bdfc041d5707 (diff)
QGestureManager: fix expensive iteration over QHash::keys()
... with iteration over the hash itself. gesturesByType is a local variable, so there's no way functions called in the loop can modify it. Change-Id: I5971c404f4ae8473d4926b68eb7a9c60801f208d Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index b5d3a56d3f..533ed6ac81 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -569,13 +569,13 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
}
// for each gesture type
- foreach (Qt::GestureType type, gestureByTypes.keys()) {
- QHash<QWidget *, QGesture *> gestures = gestureByTypes.value(type);
+ for (GestureByTypes::const_iterator git = gestureByTypes.cbegin(), gend = gestureByTypes.cend(); git != gend; ++git) {
+ const QHash<QWidget *, QGesture *> &gestures = git.value();
foreach (QWidget *widget, gestures.keys()) {
QWidget *w = widget->parentWidget();
while (w) {
QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it
- = w->d_func()->gestureContext.constFind(type);
+ = w->d_func()->gestureContext.constFind(git.key());
if (it != w->d_func()->gestureContext.constEnd()) {
// i.e. 'w' listens to gesture 'type'
if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {