diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-06-28 16:11:07 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-08-08 21:59:49 +0200 |
commit | 8b1b07c872bc7457ab1381c9c826d53fbc7ad359 (patch) | |
tree | 628647f4ef1397b50d14c39214791b94c0b60156 /src/corelib/kernel/qproperty.cpp | |
parent | 226d0981cdf1da8ca8ee53d88b663eea14de41e5 (diff) |
QProperty: Avoid needlessly refetching bindingStatus
If we already have the bindingStatus, we can just pass it along.
Change-Id: Iaaea4f4c34e6a786899561293016ece163c26d25
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 3f0a32aeb50acf17302e44dcffc3210f199de6eb)
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 0055e6a5ff..82ab3b9b59 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -154,7 +154,7 @@ struct QPropertyDelayedNotifications Change notifications are sent later with notify (following the logic of separating binding updates and notifications used in non-deferred updates). */ - void evaluateBindings(int index) { + void evaluateBindings(int index, QBindingStatus *status) { auto *delayed = delayedProperties + index; auto *bindingData = delayed->originalBindingData; if (!bindingData) @@ -170,7 +170,7 @@ struct QPropertyDelayedNotifications QPropertyBindingDataPointer bindingDataPointer{bindingData}; QPropertyObserverPointer observer = bindingDataPointer.firstObserver(); if (observer) - observer.evaluateBindings(); + observer.evaluateBindings(status); } /*! @@ -242,7 +242,8 @@ void Qt::beginPropertyUpdateGroup() */ void Qt::endPropertyUpdateGroup() { - QPropertyDelayedNotifications *& groupUpdateData = bindingStatus.groupUpdateData; + auto status = &bindingStatus; + QPropertyDelayedNotifications *& groupUpdateData = status->groupUpdateData; auto *data = groupUpdateData; Q_ASSERT(data->ref); if (--data->ref) @@ -252,7 +253,7 @@ void Qt::endPropertyUpdateGroup() auto start = data; while (data) { for (int i = 0; i < data->used; ++i) - data->evaluateBindings(i); + data->evaluateBindings(i, status); data = data->next; } // notify all delayed properties @@ -285,6 +286,8 @@ void QPropertyBindingPrivate::unlinkAndDeref() void QPropertyBindingPrivate::evaluateRecursive(QBindingStatus *status) { + if (!status) + status = &bindingStatus; return evaluateRecursive_inline(status); } @@ -435,9 +438,8 @@ QPropertyBindingData::QPropertyBindingData(QPropertyBindingData &&other) : d_ptr BindingEvaluationState::BindingEvaluationState(QPropertyBindingPrivate *binding, QBindingStatus *status) : binding(binding) { + Q_ASSERT(status); QBindingStatus *s = status; - if (!s) - s = &bindingStatus; // store a pointer to the currentBindingEvaluationState to avoid a TLS lookup in // the destructor (as these come with a non zero cost) currentState = &s->currentlyEvaluatingBinding; @@ -741,6 +743,7 @@ void QPropertyObserverPointer::noSelfDependencies(QPropertyBindingPrivate *bindi void QPropertyObserverPointer::evaluateBindings(QBindingStatus *status) { + Q_ASSERT(status); auto observer = const_cast<QPropertyObserver*>(ptr); // See also comment in notify() while (observer) { |