From 63e1cf916d5f8783634ac3c10c5be114d3711df5 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 28 Jun 2021 09:24:05 +0200 Subject: Pass QBindingStatus to evaluateBindings This avoids another round of TLS lookups in evaluateRecursive when we construct the BindingEvaluationState. Change-Id: Icfa9fd81fc6f54623d384c4d3fce33f4d4d549b9 Reviewed-by: Lars Knoll (cherry picked from commit e5aff7f3d9e90860fe24b8fe931a71e115f5413b) --- src/corelib/kernel/qproperty.cpp | 19 +++++++++---------- src/corelib/kernel/qproperty_p.h | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 09c74f1ed2..97854f8ac3 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -283,7 +283,7 @@ void QPropertyBindingPrivate::unlinkAndDeref() destroyAndFreeMemory(this); } -void QPropertyBindingPrivate::evaluateRecursive() +void QPropertyBindingPrivate::evaluateRecursive(QBindingStatus *status) { if (updating) { error = QPropertyBindingError(QPropertyBindingError::BindingLoop); @@ -304,7 +304,7 @@ void QPropertyBindingPrivate::evaluateRecursive() */ QPropertyBindingPrivatePtr keepAlive {this}; - BindingEvaluationState evaluationFrame(this); + BindingEvaluationState evaluationFrame(this, status); auto bindingFunctor = reinterpret_cast(this) + QPropertyBindingPrivate::getSizeEnsuringAlignment(); @@ -322,7 +322,7 @@ void QPropertyBindingPrivate::evaluateRecursive() return; firstObserver.noSelfDependencies(this); - firstObserver.evaluateBindings(); + firstObserver.evaluateBindings(status); } void QPropertyBindingPrivate::notifyRecursive() @@ -557,15 +557,14 @@ void QPropertyBindingData::notifyObservers(QUntypedPropertyData *propertyDataPtr if (QPropertyObserverPointer observer = d.firstObserver()) { auto status = storage ? storage->bindingStatus : nullptr; QPropertyDelayedNotifications *delay; - if (status && status->threadId == QThread::currentThreadId()) - delay = status->groupUpdateData; - else - delay = bindingStatus.groupUpdateData; + if (!status || status->threadId != QThread::currentThreadId()) + status = &bindingStatus; + delay = status->groupUpdateData; if (delay) { delay->addProperty(this, propertyDataPtr); return; } - observer.evaluateBindings(); + observer.evaluateBindings(status); } else { return; } @@ -766,7 +765,7 @@ void QPropertyObserverPointer::noSelfDependencies(QPropertyBindingPrivate *bindi } #endif -void QPropertyObserverPointer::evaluateBindings() +void QPropertyObserverPointer::evaluateBindings(QBindingStatus *status) { auto observer = const_cast(ptr); // See also comment in notify() @@ -776,7 +775,7 @@ void QPropertyObserverPointer::evaluateBindings() if (QPropertyObserver::ObserverTag(observer->next.tag()) == QPropertyObserver::ObserverNotifiesBinding) { auto bindingToEvaluate = observer->binding; QPropertyObserverNodeProtector protector(observer); - bindingToEvaluate->evaluateRecursive(); + bindingToEvaluate->evaluateRecursive(status); next = protector.next(); } diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 6c11bc45d8..96e89926db 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -112,7 +112,7 @@ struct QPropertyObserverPointer #else void noSelfDependencies(QPropertyBindingPrivate *) {} #endif - void evaluateBindings(); + void evaluateBindings(QBindingStatus *status = nullptr); void observeProperty(QPropertyBindingDataPointer property); explicit operator bool() const { return ptr != nullptr; } @@ -324,7 +324,7 @@ public: void unlinkAndDeref(); - void evaluateRecursive(); + void evaluateRecursive(QBindingStatus *status = nullptr); void notifyRecursive(); static QPropertyBindingPrivate *get(const QUntypedPropertyBinding &binding) -- cgit v1.2.3