From 49e263ef4b1f5e03012a64ec137f3f3fc540ca9b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 18 Jan 2022 19:01:04 +0100 Subject: [PATCH] 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 (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 --- src/corelib/kernel/qproperty.cpp | 5 +++++ src/corelib/kernel/qproperty_p.h | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index a4135b1f6f..32b8882369 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -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); +static_assert(std::is_trivially_destructible_v); + QPropertyBindingPrivate::~QPropertyBindingPrivate() { if (firstObserver) diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h index 5105fd6343..d80ed21102 100644 --- a/src/corelib/kernel/qproperty_p.h +++ b/src/corelib/kernel/qproperty_p.h @@ -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); - static_assert(std::is_trivially_destructible_v); using DeclarativeErrorCallback = void(*)(QPropertyBindingPrivate *); union { QPropertyBindingSourceLocation location;