summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-11-26 14:13:43 +0100
committerLars Knoll <lars.knoll@qt.io>2020-11-27 10:59:36 +0100
commitc016f3b5e40faec9d7c3ab7f7b37e53c17fcdcef (patch)
tree2776e13cebece770f3825b93ce8da4012be601c5
parentd053a72f537265c7c39ed4bf66c2413b7327ac5e (diff)
Inline the fast path for removeBinding()
Save a function call in the common case where we don't have a binding This makes a rather large performance difference for setters that do not have a binding. Change-Id: I140f29790f6fe868721a33b9fad37205e547b8e9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit c63901c5f3195596eb81e5f5ae5483ca5a0b6d35) Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/corelib/kernel/qproperty.cpp17
-rw-r--r--src/corelib/kernel/qpropertyprivate.h10
2 files changed, 17 insertions, 10 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp
index b627420d5e..bbcd1bf0fa 100644
--- a/src/corelib/kernel/qproperty.cpp
+++ b/src/corelib/kernel/qproperty.cpp
@@ -328,17 +328,18 @@ void QPropertyBindingData::evaluateIfDirty(const QUntypedPropertyData *property)
binding->evaluateIfDirtyAndReturnTrueIfValueChanged(property);
}
-void QPropertyBindingData::removeBinding()
+void QPropertyBindingData::removeBinding_helper()
{
QPropertyBindingDataPointer d{this};
- if (auto *existingBinding = d.bindingPtr()) {
- auto observer = existingBinding->takeObservers();
- d_ptr = 0;
- if (observer)
- d.setObservers(observer.ptr);
- existingBinding->unlinkAndDeref();
- }
+ auto *existingBinding = d.bindingPtr();
+ Q_ASSERT(existingBinding);
+
+ auto observer = existingBinding->takeObservers();
+ d_ptr = 0;
+ if (observer)
+ d.setObservers(observer.ptr);
+ existingBinding->unlinkAndDeref();
}
void QPropertyBindingData::registerWithCurrentlyEvaluatingBinding() const
diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h
index caf08ee5ee..951477548c 100644
--- a/src/corelib/kernel/qpropertyprivate.h
+++ b/src/corelib/kernel/qpropertyprivate.h
@@ -248,7 +248,11 @@ public:
}
void evaluateIfDirty(const QUntypedPropertyData *property) const;
- void removeBinding();
+ void removeBinding()
+ {
+ if (hasBinding())
+ removeBinding_helper();
+ }
void registerWithCurrentlyEvaluatingBinding(QtPrivate::BindingEvaluationState *currentBinding) const
{
@@ -257,8 +261,10 @@ public:
registerWithCurrentlyEvaluatingBinding_helper(currentBinding);
}
void registerWithCurrentlyEvaluatingBinding() const;
- void registerWithCurrentlyEvaluatingBinding_helper(BindingEvaluationState *currentBinding) const;
void notifyObservers(QUntypedPropertyData *propertyDataPtr) const;
+private:
+ void registerWithCurrentlyEvaluatingBinding_helper(BindingEvaluationState *currentBinding) const;
+ void removeBinding_helper();
};
template <typename T, typename Tag>