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>
bb10
Lars Knoll 2020-07-07 16:44:07 +02:00
parent 1718948ed4
commit b038575a89
2 changed files with 7 additions and 3 deletions

View File

@ -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 = &currentBindingEvaluationState;
previousState = *currentState;
*currentState = this;
binding->clearDependencyObservers();
}
BindingEvaluationState::~BindingEvaluationState()
{
currentBindingEvaluationState = previousState;
*currentState = previousState;
}
void QPropertyBase::evaluateIfDirty()

View File

@ -112,6 +112,7 @@ struct BindingEvaluationState
~BindingEvaluationState();
QPropertyBindingPrivate *binding;
BindingEvaluationState *previousState = nullptr;
BindingEvaluationState **currentState = nullptr;
};
QT_END_NAMESPACE