diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-07-07 16:44:07 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-08 11:02:03 +0200 |
commit | b038575a8995378b07e7c82cedc219c1ae40b167 (patch) | |
tree | 0a4785b6739dde2ddd8710708202148630042d25 /src | |
parent | 1718948ed493cd5306e681c21a1c2f8e22b096f4 (diff) |
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 <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 9 | ||||
-rw-r--r-- | src/corelib/kernel/qproperty_p.h | 1 |
2 files changed, 7 insertions, 3 deletions
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() diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index e5365f36fc..f15181a0ae 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -112,6 +112,7 @@ struct BindingEvaluationState ~BindingEvaluationState(); QPropertyBindingPrivate *binding; BindingEvaluationState *previousState = nullptr; + BindingEvaluationState **currentState = nullptr; }; QT_END_NAMESPACE |