]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Optimize std::is_object compilation performance
authorKen Matsui <kmatsui@gcc.gnu.org>
Thu, 30 Mar 2023 09:13:49 +0000 (02:13 -0700)
committerKen Matsui <kmatsui@gcc.gnu.org>
Sat, 16 Dec 2023 16:59:39 +0000 (08:59 -0800)
This patch optimizes the compilation performance of std::is_object
by dispatching to the new __is_object built-in trait.

libstdc++-v3/ChangeLog:
* include/std/type_traits (is_object): Use __is_object built-in
trait.
(is_object_v): Likewise.

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

index b6d0441129b6ca01e456edc7b553603d4f29daaa..2979d79a80142737c908b8fabe45bb3cec56ce1d 100644 (file)
@@ -725,11 +725,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { };
 
   /// is_object
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object)
+  template<typename _Tp>
+    struct is_object
+    : public __bool_constant<__is_object(_Tp)>
+    { };
+#else
   template<typename _Tp>
     struct is_object
     : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
                           is_void<_Tp>>>::type
     { };
+#endif
 
   template<typename>
     struct is_member_pointer;
@@ -3280,8 +3287,15 @@ template <typename _Tp>
   inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value;
 template <typename _Tp>
   inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
+
+#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_object)
+template <typename _Tp>
+  inline constexpr bool is_object_v = __is_object(_Tp);
+#else
 template <typename _Tp>
   inline constexpr bool is_object_v = is_object<_Tp>::value;
+#endif
+
 template <typename _Tp>
   inline constexpr bool is_scalar_v = is_scalar<_Tp>::value;
 template <typename _Tp>