aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-10-29 11:59:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-31 21:49:21 +0100
commitbbc36ebbc38de276b85947b65d89897bf430add5 (patch)
tree31c4a4754210fe3e97391c9dffdc31e105885390 /tests
parent7d850df7e68e0eab0f07d5f7a03050175080fb81 (diff)
Speed up lookups of imported scripts
The QQmlContextData stores the JS objects of imported scripts in a QList<PersistentValue>. 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 <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 3216f5977d..5b06c3cce9 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -3890,15 +3890,15 @@ void tst_qqmlecmascript::singletonTypeResolution()
void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
QQmlContextData *childCtxt = ctxt->childContexts;
- if (!ctxt->importedScripts.isEmpty()) {
+ if (!ctxt->importedScripts.isNullOrUndefined()) {
QV8Engine *engine = QV8Engine::get(ctxt->engine);
- foreach (const QV4::PersistentValue& qmlglobal, ctxt->importedScripts) {
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
+ QV4::Scope scope(v4);
+ QV4::ScopedArrayObject scripts(scope, ctxt->importedScripts);
+ QV4::ScopedValue qml(scope);
+ for (quint32 i = 0; i < scripts->arrayLength(); ++i) {
QQmlContextData *scriptContext, *newContext;
-
- if (qmlglobal.isUndefined())
- continue;
- QV4::Scope scope(QV8Engine::getV4((engine)));
- QV4::ScopedValue qml(scope, qmlglobal.value());
+ qml = scripts->getIndexed(i);
scriptContext = QV4::QmlContextWrapper::getContext(qml);
qml = QV4::Encode::undefined();
@@ -3910,7 +3910,7 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) {
}
engine->gc();
- qml = qmlglobal.value();
+ qml = scripts->getIndexed(i);
newContext = QV4::QmlContextWrapper::getContext(qml);
QVERIFY(scriptContext == newContext);
}