QPropertyBindingPrivate: move static_assert()s to .cpp file

One of them has managed to percolate up to the top of the Clang
-ftime-trace list of expensive template instantiations when building
libQt6Gui.so with -pch:

  **** Templates that took longest to instantiate:
    7882 ms: std::is_trivially_destructible<QPropertyBindingSourceLocation> (135 times, avg 58 ms)

The checks aren't really necessary, because the compiler would
complain about the union's deleted dtor if any of the members were not
trivially destructible. Keep it around, though, but in the .cpp file.

Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I74a513a907735bde298e0bd9557d10abbcee5c91
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Marc Mutz 2022-01-18 19:01:04 +01:00
parent a5229a57ef
commit 49e263ef4b
2 changed files with 6 additions and 2 deletions

View File

@ -267,6 +267,11 @@ void Qt::endPropertyUpdateGroup()
}
}
// check everything stored in QPropertyBindingPrivate's union is trivially destructible
// (though the compiler would also complain if that weren't the case)
static_assert(std::is_trivially_destructible_v<QPropertyBindingSourceLocation>);
static_assert(std::is_trivially_destructible_v<std::byte[sizeof(QPropertyBindingSourceLocation)]>);
QPropertyBindingPrivate::~QPropertyBindingPrivate()
{
if (firstObserver)

View File

@ -254,9 +254,8 @@ protected:
is stored somewhere else. To make efficient use of the space, we instead provide a scratch space
for QQmlPropertyBinding (which stores further binding information there).
Anything stored in the union must be trivially destructible.
(checked in qproperty.cpp)
*/
static_assert(std::is_trivially_destructible_v<QPropertyBindingSourceLocation>);
static_assert(std::is_trivially_destructible_v<std::byte[sizeof(QPropertyBindingSourceLocation)]>);
using DeclarativeErrorCallback = void(*)(QPropertyBindingPrivate *);
union {
QPropertyBindingSourceLocation location;