Hi
A minor simplification.
libstdc++: Simplify _Hashtable::_M_merge_multi
When merging two hashtable instances of the same type we do not need
to go through _M_src_hash_code that also check for identical Hash functor
type.
libstdc++-v3/ChangeLog:
* include/bits/hashtable.h
(_Hashtable<>::_M_merge_multi(_Hashtable&)):
Remove usage of _M_src_hash_code and check directly if Hash is
stateless
in the method.
Tested under Linux x64.
Ok to commit ?
François
diff --git a/libstdc++-v3/include/bits/hashtable.h
b/libstdc++-v3/include/bits/hashtable.h
index d6d76a743bb..3bcff67a377 100644
--- a/libstdc++-v3/include/bits/hashtable.h
+++ b/libstdc++-v3/include/bits/hashtable.h
@@ -1328,8 +1328,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
const auto& __node = static_cast<__node_type&>(*__prev->_M_nxt);
const key_type& __k = _ExtractKey{}(__node._M_v());
- // Hash code from this->hash_function():
- auto __code = _M_src_hash_code(__src.hash_function(), __k, __node);
+ __hash_code __code;
+ if constexpr (std::is_empty_v<_Hash>)
+ // If the node has a cached hash code, it's OK to use it.
+ __code = this->_M_hash_code(__node);
+ else
+ __code = this->_M_hash_code(__k);
+
// Bucket index in __src, using code from __src.hash_function():
size_type __src_bkt = __src._M_bucket_index(__node);
auto __nh = __src._M_extract_node(__src_bkt, __prev);