summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-06-25 15:10:23 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-04 23:10:19 +0000
commit7aac325c3482089eb1441e91fe31672ce4f19f60 (patch)
treec2243a088663916b26f79533de1f06223462cf72 /src/corelib/kernel/qproperty.cpp
parent83ef7ff7f9d362b73da4de471513ce0b7d7cd117 (diff)
Avoid TLS access for groupUpdateData
By putting the groupUpdateData pointer into the same thread local as the binding status, we avoid having to fetch two thread_local variables. Moreover, we can reuse the caching mechanism which we have in place for QBindingStatus to avoid costly TLS lookups. Change-Id: Iaea515763510daab83f89b8e74f35a80965d6965 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 71fea09e1a8d1fc5d9cca7c504f45b77725c0e21) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r--src/corelib/kernel/qproperty.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp
index 50ec3807d3..db202ad725 100644
--- a/src/corelib/kernel/qproperty.cpp
+++ b/src/corelib/kernel/qproperty.cpp
@@ -198,7 +198,7 @@ struct QPropertyDelayedNotifications
}
};
-static thread_local QPropertyDelayedNotifications *groupUpdateData = nullptr;
+static thread_local QBindingStatus bindingStatus;
/*!
\since 6.2
@@ -222,6 +222,7 @@ static thread_local QPropertyDelayedNotifications *groupUpdateData = nullptr;
*/
void Qt::beginPropertyUpdateGroup()
{
+ QPropertyDelayedNotifications *& groupUpdateData = bindingStatus.groupUpdateData;
if (!groupUpdateData)
groupUpdateData = new QPropertyDelayedNotifications;
++groupUpdateData->ref;
@@ -241,6 +242,7 @@ void Qt::beginPropertyUpdateGroup()
*/
void Qt::endPropertyUpdateGroup()
{
+ QPropertyDelayedNotifications *& groupUpdateData = bindingStatus.groupUpdateData;
auto *data = groupUpdateData;
Q_ASSERT(data->ref);
if (--data->ref)
@@ -467,8 +469,6 @@ QPropertyBindingData::QPropertyBindingData(QPropertyBindingData &&other) : d_ptr
QPropertyBindingDataPointer::fixupAfterMove(this);
}
-static thread_local QBindingStatus bindingStatus;
-
BindingEvaluationState::BindingEvaluationState(QPropertyBindingPrivate *binding, QBindingStatus *status)
: binding(binding)
{
@@ -545,12 +545,22 @@ void QPropertyBindingData::registerWithCurrentlyEvaluatingBinding_helper(Binding
void QPropertyBindingData::notifyObservers(QUntypedPropertyData *propertyDataPtr) const
{
+ notifyObservers(propertyDataPtr, nullptr);
+}
+
+void QPropertyBindingData::notifyObservers(QUntypedPropertyData *propertyDataPtr, QBindingStorage *storage) const
+{
if (isNotificationDelayed())
return;
QPropertyBindingDataPointer d{this};
if (QPropertyObserverPointer observer = d.firstObserver()) {
- auto *delay = groupUpdateData;
+ auto status = storage ? storage->bindingStatus : nullptr;
+ QPropertyDelayedNotifications *delay;
+ if (status && status->threadId == QThread::currentThreadId())
+ delay = status->groupUpdateData;
+ else
+ delay = bindingStatus.groupUpdateData;
if (delay) {
delay->addProperty(this, propertyDataPtr);
return;