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 <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2021-10-16 11:30:50 +02:00
parent 44b7a1a37b
commit 80c17af940

View File

@ -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<decltype(Signal)>) {
if constexpr (SignalTakesValue::value)
(owner()->*Signal)(value());