diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-12 07:33:06 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-03-17 00:20:46 (GMT) |
commit | 4613955f735837d8007f5558db6a07ec5efb9ab5 (patch) | |
tree | 93dc06ae6f9809df003cad39aa37a77dc4bc0790 | |
parent | a88c755e511d3aea726bd0e096621054af18ce01 (diff) | |
download | Qt-4613955f735837d8007f5558db6a07ec5efb9ab5.zip Qt-4613955f735837d8007f5558db6a07ec5efb9ab5.tar.gz Qt-4613955f735837d8007f5558db6a07ec5efb9ab5.tar.bz2 |
Optimization: Use id notifier for QtScript bindings
-rw-r--r-- | src/declarative/qml/qdeclarativecontextscriptclass.cpp | 9 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine_p.h | 5 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeexpression.cpp | 24 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/declarative/qml/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp index 874eeac..0e5066e 100644 --- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp +++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp @@ -252,6 +252,9 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name) QScriptValue rv; if (lastPropertyIndex < cp->idValueCount) { rv = ep->objectClass->newQObject(cp->idValues[lastPropertyIndex].data()); + + if (ep->captureProperties) + ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(&cp->idValues[lastPropertyIndex].bindings); } else { const QVariant &value = cp->propertyValues.at(lastPropertyIndex); if (value.userType() == qMetaTypeId<QList<QObject*> >()) { @@ -259,10 +262,10 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name) } else { rv = ep->scriptValueFromVariant(value); } - } - if (ep->captureProperties) - ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex); + if (ep->captureProperties) + ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex); + } return Value(scriptEngine, rv); diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index c73a758..fb8c5e7 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -144,10 +144,13 @@ public: struct CapturedProperty { CapturedProperty(QObject *o, int c, int n) - : object(o), coreIndex(c), notifyIndex(n) {} + : object(o), coreIndex(c), notifier(0), notifyIndex(n) {} + CapturedProperty(QDeclarativeNotifier *n) + : object(0), coreIndex(-1), notifier(n), notifyIndex(-1) {} QObject *object; int coreIndex; + QDeclarativeNotifier *notifier; int notifyIndex; }; bool captureProperties; diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 5ff22f7..f3299ba 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -656,7 +656,29 @@ void QDeclarativeExpressionPrivate::updateGuards(const QPODVector<QDeclarativeEn guard.target = q; guard.targetMethod = notifyIdx; - if (property.notifyIndex != -1) { + if (property.notifier != 0) { + + if (!noChanges && guard.isConnected(property.notifier)) { + // Nothing to do + + } else { + noChanges = false; + + bool existing = false; + for (int jj = 0; !existing && jj < ii; ++jj) + if (data->guardList[jj].isConnected(property.notifier)) + existing = true; + + if (existing) { + // duplicate + guard.disconnect(); + } else { + guard.connect(property.notifier); + } + } + + + } else if (property.notifyIndex != -1) { if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) { // Nothing to do |