QQuickWindow: Move itemsToPolish from a QSet to QVector.
authorRobin Burchell <robin.burchell@viroteck.net>
Tue, 2 Jun 2015 17:27:21 +0000 (20:27 +0300)
committerRobin Burchell <robin.burchell@viroteck.net>
Sat, 6 Jun 2015 11:33:24 +0000 (11:33 +0000)
QQuickItem already keeps track of whether the polish flag has been set, so the
set provided no functional advantage here, and would have served to pessimize
processing of polish if anything - now adding items to polish and processing
them becomes constant-time operations.

The only operation that is pessimised is removing polish off an existing item:
but this should not be too horrid, unless the number of items to polish stacks
up tremendously.

Change-Id: I5d26dc899570a1e0186018850c21659e1f60a6b3
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
src/quick/items/qquickitem.cpp
src/quick/items/qquickwindow.cpp
src/quick/items/qquickwindow_p.h

index 3d0f550..e6ab69e 100644 (file)
@@ -2776,7 +2776,7 @@ void QQuickItemPrivate::refWindow(QQuickWindow *c)
     window = c;
 
     if (polishScheduled)
-        QQuickWindowPrivate::get(window)->itemsToPolish.insert(q);
+        QQuickWindowPrivate::get(window)->itemsToPolish.append(q);
 
     if (!parentItem)
         QQuickWindowPrivate::get(window)->parentlessItems.insert(q);
@@ -2808,7 +2808,7 @@ void QQuickItemPrivate::derefWindow()
     removeFromDirtyList();
     QQuickWindowPrivate *c = QQuickWindowPrivate::get(window);
     if (polishScheduled)
-        c->itemsToPolish.remove(q);
+        c->itemsToPolish.removeOne(q);
     QMutableHashIterator<int, QQuickItem *> itemTouchMapIt(c->itemForTouchPointId);
     while (itemTouchMapIt.hasNext()) {
         if (itemTouchMapIt.next().value() == q)
@@ -4102,7 +4102,7 @@ void QQuickItem::polish()
         if (d->window) {
             QQuickWindowPrivate *p = QQuickWindowPrivate::get(d->window);
             bool maybeupdate = p->itemsToPolish.isEmpty();
-            p->itemsToPolish.insert(this);
+            p->itemsToPolish.append(this);
             if (maybeupdate) d->window->maybeUpdate();
         }
     }
index ee2556a..d7304ce 100644 (file)
@@ -259,8 +259,7 @@ void QQuickWindowPrivate::polishItems()
     // the user.
     int recursionSafeguard = INT_MAX;
     while (!itemsToPolish.isEmpty() && --recursionSafeguard > 0) {
-        QQuickItem *item = *itemsToPolish.begin();
-        itemsToPolish.remove(item);
+        QQuickItem *item = itemsToPolish.takeLast();
         QQuickItemPrivate::get(item)->polishScheduled = false;
         item->updatePolish();
     }
index 605a36f..0d33d23 100644 (file)
@@ -200,7 +200,7 @@ public:
     QQuickItem *dirtyItemList;
     QList<QSGNode *> cleanupNodeList;
 
-    QSet<QQuickItem *> itemsToPolish;
+    QVector<QQuickItem *> itemsToPolish;
 
     void updateDirtyNodes();
     void cleanupNodes();