diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-11-25 13:05:37 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-11-30 23:02:29 +0000 |
commit | ba0e0129023a4454ddb03f6375dbbe5eb2b8dabb (patch) | |
tree | a3957f4347db54611a8bbfe6bdb67b2ddca2c0c3 /src/corelib/kernel/qproperty.cpp | |
parent | 76743374e75df72311f25349b1274256eaddfc75 (diff) |
Inline the fast path of a few methods
No need to do function calls for the case where we return immediately
after checking a boolean.
Change-Id: I3e449850a10fcf82acb843cce6da6dfd98de32ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e165f416a752398079590161a18255f9a0058a3e)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index d6d58bc448..01204199cb 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -123,10 +123,9 @@ void QPropertyBindingPrivate::markDirtyAndNotifyObservers() staticObserverCallback(propertyDataPtr); } -bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged(const QUntypedPropertyData *data) +bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged_helper(const QUntypedPropertyData *data, QBindingStatus *status) { - if (!dirty) - return false; + Q_ASSERT(dirty); if (updating) { error = QPropertyBindingError(QPropertyBindingError::BindingLoop); @@ -144,7 +143,7 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged(const Q QPropertyBindingPrivatePtr keepAlive {this}; QScopedValueRollback<bool> updateGuard(updating, true); - BindingEvaluationState evaluationFrame(this); + BindingEvaluationState evaluationFrame(this, status); bool changed = false; @@ -288,22 +287,17 @@ QPropertyBindingData::QPropertyBindingData(QPropertyBindingData &&other) : d_ptr d.fixupFirstObserverAfterMove(); } -QPropertyBindingPrivate *QPropertyBindingData::binding() const -{ - QPropertyBindingDataPointer d{this}; - if (auto binding = d.bindingPtr()) - return binding; - return nullptr; -} - static thread_local QBindingStatus bindingStatus; -BindingEvaluationState::BindingEvaluationState(QPropertyBindingPrivate *binding) +BindingEvaluationState::BindingEvaluationState(QPropertyBindingPrivate *binding, QBindingStatus *status) : binding(binding) { + QBindingStatus *s = status; + if (!s) + s = &bindingStatus; // store a pointer to the currentBindingEvaluationState to avoid a TLS lookup in // the destructor (as these come with a non zero cost) - currentState = &bindingStatus.currentlyEvaluatingBinding; + currentState = &s->currentlyEvaluatingBinding; previousState = *currentState; *currentState = this; binding->clearDependencyObservers(); @@ -352,7 +346,12 @@ void QPropertyBindingData::registerWithCurrentlyEvaluatingBinding() const auto currentState = bindingStatus.currentlyEvaluatingBinding; if (!currentState) return; + registerWithCurrentlyEvaluatingBinding_helper(currentState); +} + +void QPropertyBindingData::registerWithCurrentlyEvaluatingBinding_helper(BindingEvaluationState *currentState) const +{ QPropertyBindingDataPointer d{this}; QPropertyObserverPointer dependencyObserver = currentState->binding->allocateDependencyObserver(); |