Speed up creation of objects that don't import scripts
authorSimon Hausmann <simon.hausmann@theqtcompany.com>
Fri, 10 Apr 2015 13:53:02 +0000 (15:53 +0200)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Thu, 16 Apr 2015 10:56:06 +0000 (10:56 +0000)
In the common case of no 'import "Foo.js" as Bar' we can avoid the creation of
the JS array that holds the script references.

Change-Id: I6704bd9efaf8681f939a148b2cb0a1de2cb22d80
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/qqmlobjectcreator.cpp

index a32dc9e0a9b63d032a376f573bbf5ec3ce15a200..76c45371037548bbe1582388cd1d67ea95c672ff 100644 (file)
@@ -206,7 +206,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI
     }
     context->setIdPropertyData(mapping);
 
-    if (subComponentIndex == -1) {
+    if (subComponentIndex == -1 && compiledData->scripts.count()) {
         QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count()));
         context->importedScripts.set(v4, scripts);
         for (int i = 0; i < compiledData->scripts.count(); ++i) {