diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-10-10 13:52:34 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-12 01:31:11 +0200 |
commit | 0466acb02740b5dbf3254d6445186b4d3ccd0699 (patch) | |
tree | a1b7314c2faae73cf93403afdc7ca92f2106d70d /src/declarative/qml/qdeclarativeexpression_p.h | |
parent | 3422d4adda7480a44a063ab86447c2fe2792fe02 (diff) |
Optimize signal handling
Bindings connect to lots of signals that are never emitted. By managing
signal connection lists ourselves, we can do a much better job than Qt's
generic signal/slot connection logic.
Also, by connecting to QDeclarativeNotifierEndpoint's rather than QObject
slots, we can eliminate the need to instantiate a QObject for the V4 and
V8 binding managers.
Change-Id: I598667deaefdbd2860227bd74378a1b196761686
Reviewed-on: http://codereview.qt-project.org/6278
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Sanity-Review: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativeexpression_p.h')
-rw-r--r-- | src/declarative/qml/qdeclarativeexpression_p.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h index 9feea5ca22..4e31efb806 100644 --- a/src/declarative/qml/qdeclarativeexpression_p.h +++ b/src/declarative/qml/qdeclarativeexpression_p.h @@ -147,11 +147,12 @@ public: void setNotifyOnValueChanged(bool v); void resetNotifyOnValueChanged(); - void setNotifyObject(QObject *, int ); inline QObject *scopeObject() const; inline void setScopeObject(QObject *v); + virtual void expressionChanged() {} + protected: inline virtual QString expressionIdentifier(); @@ -162,8 +163,6 @@ private: quint32 m_dummy:29; QObject *m_scopeObject; - QObject *m_notifyObject; - int m_notifyIndex; class GuardList { public: @@ -172,11 +171,18 @@ private: void inline clear(); typedef QPODVector<QDeclarativeEnginePrivate::CapturedProperty> CapturedProperties; - void updateGuards(QObject *guardObject, int guardObjectNotifyIndex, - QDeclarativeJavaScriptExpression *, const CapturedProperties &properties); + void updateGuards(QDeclarativeJavaScriptExpression *, const CapturedProperties &properties); private: - QDeclarativeNotifierEndpoint *endpoints; + struct Endpoint : public QDeclarativeNotifierEndpoint { + Endpoint() : expression(0) { callback = &endpointCallback; } + static void endpointCallback(QDeclarativeNotifierEndpoint *e) { + static_cast<Endpoint *>(e)->expression->expressionChanged(); + } + QDeclarativeJavaScriptExpression *expression; + }; + + Endpoint *endpoints; int length; }; GuardList guardList; @@ -203,7 +209,7 @@ public: static inline QDeclarativeExpression *get(QDeclarativeExpressionPrivate *expr); void _q_notify(); - virtual void emitValueChanged(); + virtual void expressionChanged(); static void exceptionToError(v8::Handle<v8::Message>, QDeclarativeError &); static v8::Persistent<v8::Function> evalFunction(QDeclarativeContextData *ctxt, QObject *scope, |