From b038575a8995378b07e7c82cedc219c1ae40b167 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 7 Jul 2020 16:44:07 +0200 Subject: Get rid of one call into the TLS when evaluating bindings Store a pointer to the TLS in the BingingEvaluationState. Like this, we can save us one TLS lookup in the destructor. Shaves off a couple of percent during binding evaluation. Change-Id: Idc9dc5b0ea202aaeb68cdc063700b8e4968753dc Reviewed-by: Ulf Hermann --- src/corelib/kernel/qproperty.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/corelib/kernel/qproperty.cpp') diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index f62810518b..beba05c01e 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -193,14 +193,17 @@ static thread_local BindingEvaluationState *currentBindingEvaluationState = null BindingEvaluationState::BindingEvaluationState(QPropertyBindingPrivate *binding) : binding(binding) { - previousState = currentBindingEvaluationState; - currentBindingEvaluationState = this; + // store a pointer to the currentBindingEvaluationState to avoid a TLS lookup in + // the destructor (as these come with a non zero cost) + currentState = ¤tBindingEvaluationState; + previousState = *currentState; + *currentState = this; binding->clearDependencyObservers(); } BindingEvaluationState::~BindingEvaluationState() { - currentBindingEvaluationState = previousState; + *currentState = previousState; } void QPropertyBase::evaluateIfDirty() -- cgit v1.2.3