public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r13-2698] libstdc++: Remove __alloc_neq helper
Date: Fri, 16 Sep 2022 15:02:12 +0000 (GMT)	[thread overview]
Message-ID: <20220916150212.EEE29389A12F@sourceware.org> (raw)

https://gcc.gnu.org/g:15943285867a6952dbc5a603c434e61bfe32296f

commit r13-2698-g15943285867a6952dbc5a603c434e61bfe32296f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Sep 16 11:39:41 2022 +0100

    libstdc++: Remove __alloc_neq helper
    
    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.

Diff:
---
 libstdc++-v3/include/bits/allocator.h | 17 -----------------
 libstdc++-v3/include/bits/stl_list.h  |  5 ++---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h
index 28abf13eba9..c39166e24fe 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -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>,
diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h
index b8bd46191fc..a73ca60df5a 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -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();
       }

                 reply	other threads:[~2022-09-16 15:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220916150212.EEE29389A12F@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).