]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: [_Hashtable] Remove useless check for _M_before_begin node
authorHuanghui Nie <nnnjkk@gmail.com>
Mon, 22 Jan 2024 05:45:48 +0000 (06:45 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Wed, 24 Jan 2024 05:36:04 +0000 (06:36 +0100)
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>
libstdc++-v3/include/bits/hashtable.h

index b48610036fad70f88bc16ada6770c31e562412dd..c3ef7a0a3d5aed1ca84e87db45942a58ed3dfd46 100644 (file)
@@ -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;
          }
       }