aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@viroteck.net>2015-06-06 11:19:38 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-24 04:20:55 +0000
commitcfae39f4c1664c31b4904d288b6e0cffaf208bc2 (patch)
treee049c8d387d6b550a1d8d52ae0dd7352a268c5f0
parent15d6c938b28a03c3076abd4b8015b3e8f559a3eb (diff)
QQuickAnchors: Use a simple sorted list rather than a QSet to remove duplicates.
This is significantly less allocation-happy than QSet (removing around 30mb of transient allocations when creating 5000 instances of one of the creation benchmarks). It increases the count of delegates_tworects per frame from ~520 per frame to ~600 per frame for me. Change-Id: If7edd56890c93e0caf7957d08e80506e87491773 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
-rw-r--r--src/quick/items/qquickanchors.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp
index f559f166bf..606d4c45da 100644
--- a/src/quick/items/qquickanchors.cpp
+++ b/src/quick/items/qquickanchors.cpp
@@ -414,13 +414,27 @@ void QQuickAnchorsPrivate::updateMe()
void QQuickAnchorsPrivate::updateOnComplete()
{
//optimization to only set initial dependencies once, at completion time
- QSet<QQuickItem *> dependencies;
- dependencies << fill << centerIn
- << left.item << right.item << hCenter.item
- << top.item << bottom.item << vCenter.item << baseline.item;
-
- foreach (QQuickItem *dependency, dependencies)
- addDepend(dependency);
+ QQuickItem *dependencies[9];
+ dependencies[0] = fill;
+ dependencies[1] = centerIn;
+ dependencies[2] = left.item;
+ dependencies[3] = right.item;
+ dependencies[4] = hCenter.item;
+ dependencies[5] = top.item;
+ dependencies[6] = bottom.item;
+ dependencies[7] = vCenter.item;
+ dependencies[8] = baseline.item;
+
+ std::sort(dependencies, dependencies + 9);
+
+ QQuickItem *lastDependency = 0;
+ for (int i = 0; i < 9; ++i) {
+ QQuickItem *dependency = dependencies[i];
+ if (lastDependency != dependency) {
+ addDepend(dependency);
+ lastDependency = dependency;
+ }
+ }
update();
}