From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1720) id D9CBF3858CDB; Wed, 24 Jan 2024 05:37:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9CBF3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706074624; bh=ukoZ6UFg2pF730ENr5LboCBH9ZJ/L8v5jh6jGpl6Uaw=; h=From:To:Subject:Date:From; b=ok7SGunVouTmULyL2+m9KtEPB5nFvwCTD3D0SaY7zx65XYmjojejObUJQuLDPRcu2 FaOfNoUSRruUvSPoc2hp9aTBZOIomp5SEf4BP9wWbedYmm/yw0X62emZyk8//aHlFv KRnDGWvtJaVI5m7fg0+dDwTJaR8pZFR1A1pyf/UI= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Francois Dumont To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-8380] libstdc++: [_Hashtable] Remove useless check for _M_before_begin node X-Act-Checkin: gcc X-Git-Author: Huanghui Nie X-Git-Refname: refs/heads/master X-Git-Oldrev: 7f7d9c525c694e36ae525ed93ccd5b6ffad0f1d8 X-Git-Newrev: ec0a68b9ee3e4b3de84816ea22c82214f8a8ceb0 Message-Id: <20240124053704.D9CBF3858CDB@sourceware.org> Date: Wed, 24 Jan 2024 05:37:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ec0a68b9ee3e4b3de84816ea22c82214f8a8ceb0 commit r14-8380-gec0a68b9ee3e4b3de84816ea22c82214f8a8ceb0 Author: Huanghui Nie 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 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; } }