From 7811d1002dd7fdceb4fcb2dd7dfba73eb91fbfd8 Mon Sep 17 00:00:00 2001 From: Jarrio <748557+Jarrio@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:49:41 +0000 Subject: [PATCH] Boxed: only register a finaliser for values with a non-trivial destructor Boxed_obj chose between registering a finaliser and doing nothing with std::is_destructible, which is true for nearly every type. So values whose destructor does nothing, such as a struct of floats, were registered too. Each registration takes the finaliser lock and adds an entry to the global finaliser map, and every collection walks that map. The check is now is_destructible and not is_trivially_destructible. A trivially destructible value has no destructor to run, so nothing it needs is skipped. In an app that holds a matrix and a paint per visual this removed 43 to 45% of the live finaliser entries. --- include/cpp/marshal/Boxed.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/cpp/marshal/Boxed.hpp b/include/cpp/marshal/Boxed.hpp index 8224ffa40..5b3ecb2f9 100644 --- a/include/cpp/marshal/Boxed.hpp +++ b/include/cpp/marshal/Boxed.hpp @@ -23,20 +23,20 @@ inline void cpp::marshal::Boxed_obj::setFinaliser(std::false_type) {} template inline cpp::marshal::Boxed_obj::Boxed_obj() : value() { - setFinaliser(std::is_destructible{}); + setFinaliser(std::integral_constant::value && !std::is_trivially_destructible::value>{}); } template inline cpp::marshal::Boxed_obj::Boxed_obj(T* ptr) : value(*ptr) { - setFinaliser(std::is_destructible{}); + setFinaliser(std::integral_constant::value && !std::is_trivially_destructible::value>{}); } template template inline cpp::marshal::Boxed_obj::Boxed_obj(TArgs... args) : value(std::forward(args)...) { - setFinaliser(std::is_destructible{}); + setFinaliser(std::integral_constant::value && !std::is_trivially_destructible::value>{}); } #endif