]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Optimize std::add_lvalue_reference compilation performance
authorKen Matsui <kmatsui@gcc.gnu.org>
Thu, 15 Feb 2024 07:22:57 +0000 (23:22 -0800)
committerKen Matsui <kmatsui@gcc.gnu.org>
Thu, 13 Jun 2024 14:00:06 +0000 (07:00 -0700)
This patch optimizes the compilation performance of
std::add_lvalue_reference by dispatching to the new
__add_lvalue_reference built-in trait.

libstdc++-v3/ChangeLog:

* include/std/type_traits (__add_lval_ref_t): Use
__add_lvalue_reference 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 0ef112926575b6c1717aff9c83d0b357e785a0e0..79983ea980a18acc5b599991de7a55d7f7b7ea5a 100644 (file)
@@ -1157,6 +1157,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   /// @cond undocumented
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__add_lvalue_reference)
+  template<typename _Tp>
+    using __add_lval_ref_t = __add_lvalue_reference(_Tp);
+#else
   template<typename _Tp, typename = void>
     struct __add_lvalue_reference_helper
     { using type = _Tp; };
@@ -1167,6 +1171,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp>
     using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type;
+#endif
   /// @endcond
 
   /// is_copy_constructible