forked from qt-creator/qt-creator
QmlJS: Speed up ValueOwner construction.
* Don't build all default values (including the global object) separately for each ValueOwner instance. * Instead, keep all global, immutable values in a single, shared instance. While refactoring, some cases where we *modified* the global object had to be removed: * C++ context properties no longer get injected into the global object, instead they now have their own scope just above the global one. * The Qt object's prototype no longer gets modified in Link. Instead, it's now a reference to the "Qt" object provided in a qmltypes file. * The whole concept of a function 'Activation' that could potentially affect the global object was removed. Change-Id: Id382faf965efa747fcc7a9b0bc2c90429d84d61b Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
This commit is contained in:
@@ -100,6 +100,7 @@ ScopeChain::ScopeChain(const Document::Ptr &document, const ContextPtr &context)
|
||||
: m_document(document)
|
||||
, m_context(context)
|
||||
, m_globalScope(0)
|
||||
, m_cppContextProperties(0)
|
||||
, m_qmlTypes(0)
|
||||
, m_jsImports(0)
|
||||
, m_modified(false)
|
||||
@@ -154,6 +155,17 @@ void ScopeChain::setGlobalScope(const ObjectValue *globalScope)
|
||||
m_globalScope = globalScope;
|
||||
}
|
||||
|
||||
const ObjectValue *ScopeChain::cppContextProperties() const
|
||||
{
|
||||
return m_cppContextProperties;
|
||||
}
|
||||
|
||||
void ScopeChain::setCppContextProperties(const ObjectValue *cppContextProperties)
|
||||
{
|
||||
m_modified = true;
|
||||
m_cppContextProperties = cppContextProperties;
|
||||
}
|
||||
|
||||
QSharedPointer<const QmlComponentChain> ScopeChain::qmlComponentChain() const
|
||||
{
|
||||
return m_qmlComponentScope;
|
||||
@@ -243,6 +255,9 @@ void ScopeChain::update() const
|
||||
|
||||
m_all += m_globalScope;
|
||||
|
||||
if (m_cppContextProperties)
|
||||
m_all += m_cppContextProperties;
|
||||
|
||||
// the root scope in js files doesn't see instantiating components
|
||||
if (m_jsScopes.count() != 1 || !m_qmlScopeObjects.isEmpty()) {
|
||||
if (m_qmlComponentScope) {
|
||||
@@ -278,6 +293,7 @@ void ScopeChain::initializeRootScope()
|
||||
Bind *bind = m_document->bind();
|
||||
|
||||
m_globalScope = valueOwner->globalObject();
|
||||
m_cppContextProperties = valueOwner->cppQmlTypes().cppContextProperties();
|
||||
|
||||
QHash<const Document *, QmlComponentChain *> componentScopes;
|
||||
QmlComponentChain *chain = new QmlComponentChain(m_document);
|
||||
|
||||
Reference in New Issue
Block a user