[PATCH][Hashtable 2/6] Avoid over-sizing container

Jonathan Wakely jwakely@redhat.com
Fri Jul 17 09:43:00 GMT 2020


On 17/11/19 21:56 +0100, François Dumont wrote:
>This patch avoids over-sizing of the container by rather considering 
>the bucket count hint or potential reservation.
>
>It concerns only the non-multi containers.
>
>    * include/bits/hashtable.h
>    (_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&,
>    const _H2&, const _Hash&, const _Equal&, const _ExtractKey&,
>    const allocator_type&, __unique_keys_t)): New.
>    (_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&,
>    const _H2&, const _Hash&, const _Equal&, const _ExtractKey&,
>    const allocator_type&, __multi_keys_t)): New.
>    (_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&,
>    const _H2&, const _Hash&, const _Equal&, const _ExtractKey&,
>    const allocator_type&)): Delegate to latters.
>    (operator=(initializer_list<value_type>)): Rehash if too small.
>    (_M_insert(_Arg&&, const _NodeGenerator&, __unique_keys_t)): Remove
>    size_t len parameter.
>    * include/bits/hashtable_policy.h (_Insert_base<>::_M_insert_range):
>    Do not try to get input range distance.
>    * testsuite/23_containers/unordered_set/cons/bucket_hint.cc: New.
>    * testsuite/23_containers/unordered_set/modifiers/insert.cc: New.
>
>Tested under Linux x86_64.

OK for master.

Please update the copyright years in the new tests (sorry it took so
long to review it!)




More information about the Libstdc++ mailing list