QV4: Lower time spent in indirections and allocations.
authorRobin Burchell <robin.burchell@viroteck.net>
Sun, 21 Dec 2014 19:15:09 +0000 (20:15 +0100)
committerRobin Burchell <robin.burchell@viroteck.net>
Wed, 7 Jan 2015 20:35:58 +0000 (21:35 +0100)
Change data type for defsUntyped from QList -> QVector & reserve space when
creating the list. Drops ~250ms off a pretty morbid QML testcase, most, but not
all of which was spent in allocations.

Change-Id: I2ed8c62e7d41ab353a0194da268a2b430f079474
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/compiler/qv4ssa.cpp

index 77cfab8..69be6b3 100644 (file)
@@ -1145,9 +1145,10 @@ public:
         defUse.blockOfStatement = defBlock;
     }
 
-    QList<UntypedTemp> defsUntyped() const
+    QVector<UntypedTemp> defsUntyped() const
     {
-        QList<UntypedTemp> res;
+        QVector<UntypedTemp> res;
+        res.reserve(tempCount());
         foreach (const DefUse &du, _defUses)
             if (du.isValid())
                 res.append(UntypedTemp(du.temp));
@@ -2524,7 +2525,7 @@ public:
         Q_UNUSED(f);
 
         QVector<UntypedTemp> knownOk;
-        QList<UntypedTemp> candidates = _defUses.defsUntyped();
+        QVector<UntypedTemp> candidates = _defUses.defsUntyped();
         while (!candidates.isEmpty()) {
             UntypedTemp temp = candidates.last();
             candidates.removeLast();