]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Optimize std::decay compilation performance
authorKen Matsui <kmatsui@gcc.gnu.org>
Thu, 15 Feb 2024 12:44:54 +0000 (04:44 -0800)
committerKen Matsui <kmatsui@gcc.gnu.org>
Thu, 13 Jun 2024 12:56:36 +0000 (05:56 -0700)
This patch optimizes the compilation performance of std::decay
by dispatching to the new __decay built-in trait.

libstdc++-v3/ChangeLog:

* include/std/type_traits (decay): Use __decay built-in trait.

Signed-off-by: Ken Matsui <kmatsui@gcc.gnu.org>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/include/std/type_traits

index 23432ac43ac6bd90a90af9fa7465d3f0c7a3dde6..3d158f993a8b8d146a0335956375decdaef9aed0 100644 (file)
@@ -2278,6 +2278,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// @cond undocumented
 
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__decay)
+  template<typename _Tp>
+    struct decay
+    { using type = __decay(_Tp); };
+#else
   // Decay trait for arrays and functions, used for perfect forwarding
   // in make_pair, make_tuple, etc.
   template<typename _Up>
@@ -2309,6 +2314,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct decay<_Tp&&>
     { using type = typename __decay_selector<_Tp>::type; };
+#endif
 
   /// @cond undocumented