libstdc++: Review _Hashtable count, equal_range _M_erase(false_type,) code
authorFrançois Dumont <fdumont@gcc.gnu.org>
Mon, 20 Jan 2020 07:24:47 +0000 (08:24 +0100)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Mon, 27 Jul 2020 19:55:49 +0000 (21:55 +0200)
commitf9d98fa74800041b39b67fa204c3ad8b527df400
tree71e7d3d1fecd16d52f516bf0e0db4e79b8ed7b63
parentd60758c74af849539f5dd71a8456eea954c0f674
libstdc++: Review _Hashtable count, equal_range _M_erase(false_type,) code

Simplify operator[] implementation using find method. Review several
_Hashtable method implementations to limit the computation of bucket index.
Introduce _M_update_bbegin to simplify code.

libstdc++-v3/ChangeLog:

* include/bits/hashtable_policy.h (_Map_base<>::at): Use
_Hashtable<>::find.
(_Hashtable_base<>::_Equal_hash_code<>::_S_node_equals):New.
(_Hashtable_base<>::_M_node_equals): New, use latter.
(_Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash,
_RehashPolicy, false>::_M_equal): Adapt to use latter.
* include/bits/hashtable.h (_Hashtable<>::_M_update_bbegin): New.
(_Hashtable<>::_M_assign): Use latter.
(_Hashtable<>::_M_move_assign): Likewise.
(_Hashtable<>(_Hashtable<>&&)): Likewise.
(_Hashtable<>(_Hashtable<>&&, const allocator_type&)): Likewise.
(_Hashtable<>::swap): Likewise.
(_Hashtable<>::find): Build iterator directly from _M_find_node result.
(_Hashtable<>::count): Use _Hashtable<>::find.
(_Hashtable<>::equal_range): Likewise.
(_Hashtable<>::_M_erase(false_type, const key_type&)): Use
_M_node_equals.
libstdc++-v3/include/bits/hashtable.h
libstdc++-v3/include/bits/hashtable_policy.h