[PATCH] Enhance unordered container merge

François Dumont frs.dumont@gmail.com
Sun Nov 14 13:29:37 GMT 2021


     libstdc++: Unordered containers merge re-use hash code.

     When merging between 2 unordered containers with same hasher we can 
re-use
     the cached hash code if any.

     Use previous insert iterator as a hint for the next insert in case 
of multi container.


             * include/bits/hashtable_policy.h 
(_Hash_code_base<>::_ReuseOrComputeHash<>): New.
(_Hash_code_base<>::_M_hash_code<_H2>(const _H2&, const 
_Hash_node_value<>&)): New.
             * include/bits/hashtable.h (_Hashtable<>::_M_merge_unique): 
Use latter.
             (_Hashtable<>::_M_merge_multi): Likewise.
             * 
testsuite/23_containers/unordered_multiset/modifiers/merge.cc (test05): 
New test.
             * testsuite/23_containers/unordered_set/modifiers/merge.cc 
(test04): New test.

Tested under Linux x86_64.

Ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable_merge.patch
Type: text/x-patch
Size: 5615 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211114/3ca33ac6/attachment.bin>


More information about the Gcc-patches mailing list