diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-08 04:22:07 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-08 04:22:07 (GMT) |
commit | 6db0dd65bdb9d999f5f5bbb54808517d3d212315 (patch) | |
tree | 4934ac2cbb46745741173a39d13b996d015248d0 /src | |
parent | 83044621103a12906394a35fbdcba966171bb507 (diff) | |
download | Qt-6db0dd65bdb9d999f5f5bbb54808517d3d212315.zip Qt-6db0dd65bdb9d999f5f5bbb54808517d3d212315.tar.gz Qt-6db0dd65bdb9d999f5f5bbb54808517d3d212315.tar.bz2 |
Optimization: Improve property read speed
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 15 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass.cpp | 37 |
4 files changed, 46 insertions, 10 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index c44f6b6..3b95558 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -116,11 +116,11 @@ struct StaticQtMetaObject : public QObject }; QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) -: rootContext(0), currentExpression(0), - isDebugging(false), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), globalClass(0), - cleanup(0), erroredBindings(0), - inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), - inBeginCreate(false), networkAccessManager(0), typeManager(e), uniqueId(1) +: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), + contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), + globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0), + scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), inBeginCreate(false), + networkAccessManager(0), typeManager(e), uniqueId(1) { globalClass = new QmlGlobalScriptClass(&scriptEngine); } @@ -136,10 +136,7 @@ QUrl QmlScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url) } QmlScriptEngine::QmlScriptEngine(QmlEnginePrivate *priv) - : p(priv), - sqlQueryClass(0), - namedNodeMapClass(0), - nodeListClass(0) +: p(priv), sqlQueryClass(0), namedNodeMapClass(0), nodeListClass(0) { // Note that all documentation for stuff put on the global object goes in // doc/src/declarative/globalobject.qdoc diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index ad81f4e..2f177a2 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -144,6 +144,7 @@ public: int coreIndex; int notifyIndex; }; + bool captureProperties; QPODVector<CapturedProperty> capturedProperties; QmlContext *rootContext; diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 652c5f8..1321601 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -436,10 +436,12 @@ QVariant QmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined) QmlEnginePrivate *ep = QmlEnginePrivate::get(q->engine()); QmlExpression *lastCurrentExpression = ep->currentExpression; + bool lastCaptureProperties = ep->captureProperties; QPODVector<QmlEnginePrivate::CapturedProperty> lastCapturedProperties; ep->capturedProperties.copyAndClear(lastCapturedProperties); ep->currentExpression = q; + ep->captureProperties = data->trackChange; // This object might be deleted during the eval QmlExpressionData *localData = data; @@ -452,6 +454,7 @@ QVariant QmlExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined) } ep->currentExpression = lastCurrentExpression; + ep->captureProperties = lastCaptureProperties; // Check if we were deleted if (localData->q) { diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 7f95b8f..73dfd75 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -220,7 +220,7 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name QScriptValue sobj = scriptEngine->newQObject(obj); return sobj.property(toString(name)); } else { - if (!(lastData->flags & QmlPropertyCache::Data::IsConstant)) { + if (enginePriv->captureProperties && !(lastData->flags & QmlPropertyCache::Data::IsConstant)) { enginePriv->capturedProperties << QmlEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex); } @@ -247,6 +247,41 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); return rv; + } else if (lastData->propType == QMetaType::QReal) { + qreal rv = 0; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); + return QScriptValue(rv); + } else if (lastData->propType == QMetaType::Int) { + int rv = 0; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); + return QScriptValue(rv); + } else if (lastData->propType == QMetaType::Bool) { + bool rv = false; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); + return QScriptValue(rv); + } else if (lastData->propType == QMetaType::QString) { + QString rv; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); + return QScriptValue(rv); + } else if (lastData->propType == QMetaType::UInt) { + uint rv = 0; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); + return QScriptValue(rv); + } else if (lastData->propType == QMetaType::Float) { + float rv = 0; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); + return QScriptValue(rv); + } else if (lastData->propType == QMetaType::Double) { + double rv = 0; + void *args[] = { &rv, 0 }; + QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); + return QScriptValue(rv); } else { QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj); return enginePriv->scriptValueFromVariant(var); |