Help the compiler avoid duplicate TLS lookups

Most compilers are clever enough to optimize this out. Yet, even with
optimizations disabled, we don't want to do two TLS lookups here.

Change-Id: I822954c7cec591084d6c27c916818dab7e000ea9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ulf Hermann 2021-10-16 10:14:04 +02:00
parent c6bc549b6b
commit a182897f77

View File

@ -2318,8 +2318,10 @@ bool isAnyBindingEvaluating()
bool isPropertyInBindingWrapper(const QUntypedPropertyData *property)
{
return bindingStatus.currentCompatProperty &&
bindingStatus.currentCompatProperty->property == property;
// Accessing bindingStatus is expensive because it's thread-local. Do it only once.
if (const auto current = bindingStatus.currentCompatProperty)
return current->property == property;
return false;
}
namespace BindableWarnings {