From e850416fcffe48cc19cdbf6a01f759964815681c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 25 May 2016 14:55:44 +0200 Subject: Optimize named object handling By storing the object indices of named objects in the CompiledData::Object of a component, we can achieve two things: (1) We can eliminate the hash of vectors in QQmlCompiledData for the object-to-id mapping (2) We can store the mapping from object name to integer object id in the CompilationUnit and share it across different QQmlContextData instances (as long as it is not modified). Also added a new test that verifies the functionality of a .qml file starting with Component{} itself with object names, something that was previously only implicitly tested through some of the examples (corkboards.qml for example). Change-Id: I28c70217222dc0e5252bf5247b7e3fc4def47446 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlobjectcreator.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/qml/qml/qqmlobjectcreator.cpp') diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 215423cb6d..a6b24c4f16 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -158,10 +158,8 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI int objectToCreate; if (subComponentIndex == -1) { - namedObjects = compiledData->namedObjectsInRootScope; objectToCreate = qmlUnit->indexOfRootObject; } else { - namedObjects = compiledData->namedObjectsPerComponent[subComponentIndex]; const QV4::CompiledData::Object *compObj = qmlUnit->objectAt(subComponentIndex); objectToCreate = compObj->bindingTable()->value.objectIndex; } @@ -170,7 +168,7 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI context->isInternal = true; context->imports = compiledData->importCache; context->imports->addref(); - context->typeCompilationUnit = compiledData->compilationUnit; + context->initFromTypeCompilationUnit(compiledData->compilationUnit, subComponentIndex); context->setParent(parentContext); if (!sharedState->rootContext) { @@ -185,8 +183,6 @@ QObject *QQmlObjectCreator::create(int subComponentIndex, QObject *parent, QQmlI if (topLevelCreator) sharedState->allJavaScriptObjects = scope.alloc(compiledData->totalObjectCount); - context->setNamedObjects(namedObjects); - if (subComponentIndex == -1 && compiledData->scripts.count()) { QV4::ScopedObject scripts(scope, v4->newArrayObject(compiledData->scripts.count())); context->importedScripts.set(v4, scripts); -- cgit v1.2.3