]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Remove __alloc_neq helper
authorJonathan Wakely <jwakely@redhat.com>
Fri, 16 Sep 2022 10:39:41 +0000 (11:39 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 16 Sep 2022 14:54:41 +0000 (15:54 +0100)
This class template and partial specialization were added 15 years ago
to optimize allocator equality comparisons in std::list. I think it's
safe to assume that GCC is now capable of optimizing an inline
operator!= that just returns false at least as well as an inline member
function that just returns false.

libstdc++-v3/ChangeLog:

* include/bits/allocator.h (__alloc_neq): Remove.
* include/bits/stl_list.h (list::_M_check_equal_allocators):
Compare allocators directly, without __alloc_neq.

libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/bits/stl_list.h

index 28abf13eba937821fd91d58fa1ac5b607d4a064b..c39166e24feb6f0ce31a3607ebfba70f8191e383 100644 (file)
@@ -298,23 +298,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
     };
 
-  // Optimize for stateless allocators.
-  template<typename _Alloc, bool = __is_empty(_Alloc)>
-    struct __alloc_neq
-    {
-      static bool
-      _S_do_it(const _Alloc&, const _Alloc&)
-      { return false; }
-    };
-
-  template<typename _Alloc>
-    struct __alloc_neq<_Alloc, false>
-    {
-      static bool
-      _S_do_it(const _Alloc& __one, const _Alloc& __two)
-      { return __one != __two; }
-    };
-
 #if __cplusplus >= 201103L
   template<typename _Tp, bool
     = __or_<is_copy_constructible<typename _Tp::value_type>,
index b8bd46191fce852f8ea639c3d670230ff3ad5767..a73ca60df5a001f339d33473d63a228b135b4071 100644 (file)
@@ -2026,10 +2026,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 
       // To implement the splice (and merge) bits of N1599.
       void
-      _M_check_equal_allocators(list& __x) _GLIBCXX_NOEXCEPT
+      _M_check_equal_allocators(const list& __x) _GLIBCXX_NOEXCEPT
       {
-       if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
-           _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
+       if (_M_get_Node_allocator() != __x._M_get_Node_allocator())
          __builtin_abort();
       }