diff options
author | François Dumont <fdumont@gcc.gnu.org> | 2019-06-17 10:25:04 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-06-17 11:25:04 +0100 |
commit | b0c849fadb128b64ddec6b4981971cbe79bd757f (patch) | |
tree | 5209e2e39ec4b61a054aea1f3e3fc283e420d0d4 /gcc | |
parent | e67ddda63ca523614921f2baaf3d571791d32d1a (diff) | |
download | gcc-b0c849fadb128b64ddec6b4981971cbe79bd757f.zip gcc-b0c849fadb128b64ddec6b4981971cbe79bd757f.tar.gz gcc-b0c849fadb128b64ddec6b4981971cbe79bd757f.tar.bz2 |
Simplify node ownership in _Hashtable members
Introduce an RAII type to manage nodes in unordered containers while
they are being inserted. If the caller always owns a node until it is
inserted, then the insertion functions don't need to deallocate on
failure. This allows a FIXME in the node re-insertion API to be removed.
Also change extract(const key_type&) to not call extract(const_iterator)
anymore. This avoids looping through the bucket nodes again to find the
node before the one being extracted.
2019-06-17 François Dumont <fdumont@gcc.gnu.org>
Jonathan Wakely <jwakely@redhat.com>
* include/bits/hashtable.h (struct _Hashtable::_Scoped_node): New type.
(_Hashtable::_M_insert_unique_node): Add key_type parameter. Don't
deallocate node if insertion fails.
(_Hashtable::_M_insert_multi_node): Likewise.
(_Hashtable::_M_reinsert_node): Pass additional key argument.
(_Hashtable::_M_reinsert_node_multi): Likewise. Remove FIXME.
(_Hashtable::_M_extract_node(size_t, __node_base*)): New function.
(_Hashtable::extract(const_iterator)): Use _M_extract_node.
(_Hashtable::extract(const _Key&)): Likewise.
(_Hashtable::_M_merge_unique): Pass additional key argument.
(_Hashtable::_M_emplace<Args>(true_type, Args&&...)): Likewise. Use
_Scoped_node.
(_Hashtable::_M_insert): Likewise.
* include/bits/hashtable_policy.h (_Map_base::operator[]): Likewise.
(_Hashtable_alloc): Add comments to functions with misleading names.
Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>
From-SVN: r272381
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions