From 80c17af9405ed2e230789868e34e98d9c94fbebf Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Sat, 16 Oct 2021 11:30:50 +0200 Subject: QProperty: Don't needlessly calculate inBindingWrapper() If there is no binding data, we don't need it. inBindingWrapper() involves a TLS lookup. Pick-to: 6.2 Change-Id: I829f314d708b80821e907124eef4aec758bbbc6a Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qproperty_p.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 742ef446ca..0e1c87f13d 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -486,11 +486,11 @@ public: void setValue(parameter_type t) { QBindingStorage *storage = qGetBindingStorage(owner()); - auto *bd = storage->bindingData(this); - // make sure we don't remove the binding if called from the bindingWrapper - const bool inWrapper = inBindingWrapper(storage); - if (bd && !inWrapper) - bd->removeBinding(); + if (auto *bd = storage->bindingData(this)) { + // make sure we don't remove the binding if called from the bindingWrapper + if (!inBindingWrapper(storage)) + bd->removeBinding(); + } this->val = t; } @@ -537,20 +537,20 @@ public: void removeBindingUnlessInWrapper() { QBindingStorage *storage = qGetBindingStorage(owner()); - auto *bd = storage->bindingData(this); - // make sure we don't remove the binding if called from the bindingWrapper - const bool inWrapper = inBindingWrapper(storage); - if (bd && !inWrapper) - bd->removeBinding(); + if (auto *bd = storage->bindingData(this)) { + // make sure we don't remove the binding if called from the bindingWrapper + if (!inBindingWrapper(storage)) + bd->removeBinding(); + } } void notify() { QBindingStorage *storage = qGetBindingStorage(owner()); - auto bd = storage->bindingData(this, false); - const bool inWrapper = inBindingWrapper(storage); - if (bd && !inWrapper) - notify(bd); + if (auto bd = storage->bindingData(this, false)) { + if (!inBindingWrapper(storage)) + notify(bd); + } if constexpr (!std::is_null_pointer_v) { if constexpr (SignalTakesValue::value) (owner()->*Signal)(value()); -- cgit v1.2.3