From bf330a8f034a8d6198a78f87d23eafc5ef7e6ffb Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 26 Dec 2019 19:35:55 +0100 Subject: [PATCH] QGestureManager: fix one (of many) inefficient loop(s) I showed QGestureManager to a colleage and I just couldn't avert my eyes... Also remove a pointless container::clear() call (the data member's dtor will do that implicitly). Change-Id: Id2b3f471d62e5ea416e875f28ecee73f8614a469 Reviewed-by: Giuseppe D'Angelo --- src/widgets/kernel/qgesturemanager.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 5604391059..541519245e 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -105,11 +105,10 @@ QGestureManager::QGestureManager(QObject *parent) QGestureManager::~QGestureManager() { qDeleteAll(m_recognizers); - foreach (QGestureRecognizer *recognizer, m_obsoleteGestures.keys()) { - qDeleteAll(m_obsoleteGestures.value(recognizer)); - delete recognizer; + for (auto it = m_obsoleteGestures.cbegin(), end = m_obsoleteGestures.cend(); it != end; ++it) { + qDeleteAll(it.value()); + delete it.key(); } - m_obsoleteGestures.clear(); } Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer)