public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8380] libstdc++: [_Hashtable] Remove useless check for _M_before_begin node
@ 2024-01-24  5:37 Francois Dumont
  0 siblings, 0 replies; only message in thread
From: Francois Dumont @ 2024-01-24  5:37 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:ec0a68b9ee3e4b3de84816ea22c82214f8a8ceb0

commit r14-8380-gec0a68b9ee3e4b3de84816ea22c82214f8a8ceb0
Author: Huanghui Nie <nnnjkk@gmail.com>
Date:   Mon Jan 22 06:45:48 2024 +0100

    libstdc++: [_Hashtable] Remove useless check for _M_before_begin node
    
    When removing the first node of a bucket it is useless to check if this bucket
    is the one containing the _M_before_begin node. The bucket before-begin node is
    already transfered to the next pointed-to bucket regardeless if it is the container
    before-begin node.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/hashtable.h (_Hahstable<>::_M_remove_bucket_begin): Remove
            _M_before_begin check and cleanup implementation.
    
    Co-authored-by: Théo Papadopoulo  <papadopoulo@gmail.com>

Diff:
---
 libstdc++-v3/include/bits/hashtable.h | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h
index b48610036fa..c3ef7a0a3d5 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -869,16 +869,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _M_remove_bucket_begin(size_type __bkt, __node_ptr __next_n,
 			     size_type __next_bkt)
       {
-	if (!__next_n || __next_bkt != __bkt)
+	if (!__next_n)
+	  _M_buckets[__bkt] = nullptr;
+	else if (__next_bkt != __bkt)
 	  {
-	    // Bucket is now empty
-	    // First update next bucket if any
-	    if (__next_n)
-	      _M_buckets[__next_bkt] = _M_buckets[__bkt];
-
-	    // Second update before begin node if necessary
-	    if (&_M_before_begin == _M_buckets[__bkt])
-	      _M_before_begin._M_nxt = __next_n;
+	    _M_buckets[__next_bkt] = _M_buckets[__bkt];
 	    _M_buckets[__bkt] = nullptr;
 	  }
       }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-24  5:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-24  5:37 [gcc r14-8380] libstdc++: [_Hashtable] Remove useless check for _M_before_begin node Francois Dumont

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).