diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-01-15 11:30:26 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-01-15 13:08:59 +0000 |
commit | 52874a0e6f739ce410c8401e19b0a9ef6d02cabf (patch) | |
tree | 1baf9aaeb7484978930fd1abe4f4fd8dc68bbc4c /src/quick/items/qquickitem.cpp | |
parent | ceba0c6b9a0ac3b50f460572ba95bbbedbbaccae (diff) |
Optimizations for Repeater::clear() and ~QQmlItem()
QQmlRepeater::clear() had quadratic complexity in the number
of items, because the items where removed from the back.
Fix this by searching the cache from the back as well
as searching for child items to remove from the back.
Change-Id: I92e491a8abf47cee9d382ef15cd2471f722fa6dd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index af60ab879b..54cb8be5da 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2375,9 +2375,8 @@ QQuickItem::~QQuickItem() else if (d->window) d->derefWindow(); - // XXX todo - optimize while (!d->childItems.isEmpty()) - d->childItems.constFirst()->setParentItem(0); + d->childItems.constLast()->setParentItem(0); if (!d->changeListeners.isEmpty()) { const auto listeners = d->changeListeners; // NOTE: intentional copy (QTBUG-54732) @@ -2953,7 +2952,8 @@ void QQuickItemPrivate::removeChild(QQuickItem *child) Q_ASSERT(child); Q_ASSERT(childItems.contains(child)); - childItems.removeOne(child); + int idx = childItems.lastIndexOf(child); + childItems.removeAt(idx); Q_ASSERT(!childItems.contains(child)); QQuickItemPrivate *childPrivate = QQuickItemPrivate::get(child); |