QGestureManager: use op[] instead of contains() + insert() to ensure an entry exists

... in an associative container.

This is more efficient (one lookup instead of two).

Change-Id: I07f1ffebb9b27714c0694658366f750752ea438c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
This commit is contained in:
Marc Mutz 2017-05-29 21:11:07 +02:00
parent 4008400060
commit a6351be355

View File

@ -143,10 +143,9 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type)
{
QList<QGestureRecognizer *> list = m_recognizers.values(type);
while (QGestureRecognizer *recognizer = m_recognizers.take(type)) {
if (!m_obsoleteGestures.contains(recognizer)) {
// inserting even an empty QSet will cause the recognizer to be deleted on destruction of the manager
m_obsoleteGestures.insert(recognizer, QSet<QGesture *>());
}
// ensuring an entry exists causes the recognizer to be deleted on destruction of the manager
auto &gestures = m_obsoleteGestures[recognizer];
Q_UNUSED(gestures);
}
foreach (QGesture *g, m_gestureToRecognizer.keys()) {
QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g);