QV4: Use QVarLengthArray in cleanupBasicBlocks.
authorRobin Burchell <robin.burchell@viroteck.net>
Sun, 21 Dec 2014 23:00:26 +0000 (00:00 +0100)
committerRobin Burchell <robin.burchell@viroteck.net>
Sat, 10 Jan 2015 13:49:43 +0000 (14:49 +0100)
Avoids heap allocations, drops around ~60ms off my morbid testcase in doing so.
QBitArray is still allocating, meaning this function isn't "free", but it's now
at 0.9% of runtime vs the 1.3% it was before, so something for another day.

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

index f438f9c..718a226 100644 (file)
@@ -3412,8 +3412,7 @@ void cleanupBasicBlocks(IR::Function *function)
     // reachable through outgoing edges, starting with the start block and all exception handler
     // blocks.
     QBitArray reachableBlocks(function->basicBlockCount());
-    QVector<BasicBlock *> postponed;
-    postponed.reserve(16);
+    QVarLengthArray<BasicBlock *, 16> postponed;
     for (int i = 0, ei = function->basicBlockCount(); i != ei; ++i) {
         BasicBlock *bb = function->basicBlock(i);
         if (i == 0 || bb->isExceptionHandler())