From: Jonathan Wakely Date: Thu, 7 Nov 2024 16:51:58 +0000 (+0000) Subject: libstdc++: Improve comment for _Hashtable::_M_insert_unique_node X-Git-Tag: releases/gcc-14.3.0~760 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fe1629a68992b1b7786fab4c3b286b41abf0e54;p=thirdparty%2Fgcc.git libstdc++: Improve comment for _Hashtable::_M_insert_unique_node Clarify the effects if rehashing is needed. Document the __n_elt parameter. libstdc++-v3/ChangeLog: * include/bits/hashtable.h (_M_insert_unique_node): Improve comment. (cherry picked from commit e97179bacd067ccd3ee765632e0c034df152ccb6) --- diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 5050f34f999d..834288c747c2 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -885,9 +885,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION pair<__node_ptr, __hash_code> _M_compute_hash_code(__node_ptr __hint, const key_type& __k) const; - // Insert node __n with hash code __code, in bucket __bkt if no - // rehash (assumes no element with same key already present). + // Insert node __n with hash code __code, in bucket __bkt (or another + // bucket if rehashing is needed). + // Assumes no element with equivalent key is already present. // Takes ownership of __n if insertion succeeds, throws otherwise. + // __n_elt is an estimated number of elements we expect to insert, + // used as a hint for rehashing when inserting a range. iterator _M_insert_unique_node(size_type __bkt, __hash_code, __node_ptr __n, size_type __n_elt = 1);