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. This dividing operation would greatly benefit from a splice operation in QHash... Change-Id: Ifd241d2da9c6998c2ad0b08294fca84d5b188d0f Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
e475017753
commit
08e0963e08
@ -571,7 +571,8 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
|
||||
// for each gesture 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()) {
|
||||
for (QHash<QWidget *, QGesture *>::const_iterator wit = gestures.cbegin(), wend = gestures.cend(); wit != wend; ++wit) {
|
||||
QWidget *widget = wit.key();
|
||||
QWidget *w = widget->parentWidget();
|
||||
while (w) {
|
||||
QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it
|
||||
@ -580,7 +581,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
|
||||
// i.e. 'w' listens to gesture 'type'
|
||||
if (!(it.value() & Qt::DontStartGestureOnChildren) && w != widget) {
|
||||
// conflicting gesture!
|
||||
(*conflicts)[widget].append(gestures[widget]);
|
||||
(*conflicts)[widget].append(wit.value());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -591,7 +592,7 @@ void QGestureManager::getGestureTargets(const QSet<QGesture*> &gestures,
|
||||
w = w->parentWidget();
|
||||
}
|
||||
if (!w)
|
||||
(*normal)[widget].append(gestures[widget]);
|
||||
(*normal)[widget].append(wit.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user