Minor optimisation: Avoid some function calls
authorLars Knoll <lars.knoll@digia.com>
Fri, 1 Mar 2013 14:02:46 +0000 (15:02 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Sun, 3 Mar 2013 08:48:42 +0000 (09:48 +0100)
Change-Id: Ie30b95af01c6623262fbbd93f51c115262531fe8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/v4/qv4object.cpp

index 3e675d3..33a3160 100644 (file)
@@ -910,8 +910,10 @@ void Object::arrayReserve(uint n)
         }
         arrayAlloc = qMax(n, 2*arrayAlloc);
         PropertyDescriptor *newArrayData = new PropertyDescriptor[arrayAlloc];
-        memcpy(newArrayData, arrayData, sizeof(PropertyDescriptor)*arrayDataLen);
-        delete [] (arrayData - off);
+        if (arrayData) {
+            memcpy(newArrayData, arrayData, sizeof(PropertyDescriptor)*arrayDataLen);
+            delete [] (arrayData - off);
+        }
         arrayData = newArrayData;
         if (sparseArray) {
             for (uint i = arrayFreeList; i < arrayAlloc; ++i) {