From bbc36ebbc38de276b85947b65d89897bf430add5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 29 Oct 2013 11:59:54 +0100 Subject: Speed up lookups of imported scripts The QQmlContextData stores the JS objects of imported scripts in a QList. Instead of indexing into that list, this patch changes ctxt->importedScripts to be a JavaScript array, that in the IR we can index via subscript. Change-Id: Ie2c35fb5294a20a0b7084bb51d19671a27195fec Reviewed-by: Lars Knoll --- src/qml/qml/qqmltypeloader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/qml/qml/qqmltypeloader.cpp') diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index 8d9c4ef2fe..1d2748de99 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2770,9 +2770,15 @@ QV4::PersistentValue QQmlScriptData::scriptValueForContext(QQmlContextData *pare ctxt->engine = parentCtxt->engine; // Fix for QTBUG-21620 } - for (int ii = 0; ii < scripts.count(); ++ii) { - ctxt->importedScripts << scripts.at(ii)->scriptData()->scriptValueForContext(ctxt); + QV4::ScopedObject scriptsArray(scope); + if (ctxt->importedScripts.isNullOrUndefined()) { + scriptsArray = v4->newArrayObject(scripts.count()); + ctxt->importedScripts = scriptsArray; + } else { + scriptsArray = ctxt->importedScripts; } + for (int ii = 0; ii < scripts.count(); ++ii) + scriptsArray->putIndexed(ii, scripts.at(ii)->scriptData()->scriptValueForContext(ctxt)); if (!hasEngine()) initialize(parentCtxt->engine); -- cgit v1.2.3