[PATCH] _Hashtable implementation cleanup

François Dumont frs.dumont@gmail.com
Wed May 10 04:59:19 GMT 2023


Hi

Rather than providing a series of patches for _Hashtable I prefer to 
submit them one by one. It will maximize the chances to have some of 
them in gcc 14.

I'm starting with this simple patch to do some cleanup in the current 
implementation to ease compiler optimizations by making some methods 
implicitly inline and avoiding the iterator abstraction when useless.

It is also replacing some faulty usages of __node_type* with __node_ptr. 
It should simplify the patch to make use of allocator custom pointer I 
would like to reactivate.

libstdc++: [_Hashtable] Implement several small methods implicitly inline

Make implementation of 3 simple _Hashtable methods implicitly inline.

Avoid usage of const_iterator abstraction within _Hashtable implementation.

Replace several usages of __node_type* with expected __node_ptr.

libstdc++-v3/ChangeLog:

             * include/bits/hashtable_policy.h
             (_NodeBuilder<>::_S_build): Use __node_ptr.
             (_ReuseOrAllocNode<>): Use __node_ptr in place of __node_type*.
             (_AllocNode<>): Likewise.
             (_Equality<>::_M_equal): Remove const_iterator usages. Only 
preserved
             to call std::is_permutation in the non-unique key 
implementation.
             * include/bits/hashtable.h 
(_Hashtable<>::_M_update_begin()): Capture
             _M_begin() once.
             (_Hashtable<>::_M_bucket_begin(size_type)): Implement 
implicitly inline.
             (_Hashtable<>::_M_insert_bucket_begin): Likewise.
             (_Hashtable<>::_M_remove_bucket_begin): Likewise.
             (_Hashtable<>::_M_compute_hash_code): Use __node_ptr rather 
than
             const_iterator.
             (_Hashtable<>::find): Likewise.
             (_Hashtable<>::_M_emplace): Likewise.
             (_Hashtable<>::_M_insert_unique): Likewise.

Ok to commit ?

François
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable.patch
Type: text/x-patch
Size: 16128 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20230510/c8c955ab/attachment-0001.bin>


More information about the Libstdc++ mailing list