On Mon, 15 Nov 2021 at 06:00, François Dumont wrote:
>
> On 15/11/21 12:25 am, Jonathan Wakely wrote:
> > On Sun, 14 Nov 2021 at 13:31, François Dumont via Libstdc++
> > <libstd...@gcc.gnu.org> wrote:
> >>       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.
> > Instead of introducing the _ReuseOrComputeHash type, wouldn't it be
> > simpler to just overload _M_hash_code?
> >
> >
> >      // Same hash function, use the cached hash code.
> >      __hash_code
> >      _M_hash_code(const _Hash&,
> >          const _Hash_node_value<_Value, true>& __n) const
> >      { return __n._M_hash_code; }
> >
> >    // Compute hash code using a different hash function, _H2
> >    template<typename _H2>
> >     __hash_code
> >     _M_hash_code(const _H2&,
> >         const _Hash_node_value<_Value, __cache_hash_code>& __n) const
> >     { return this->_M_hash_code(_ExtractKey{}(__n._M_v()); }
> >
> > The first overload is more specialized, so will be chosen when the
> > first argument is the same type as _Hash and the cache_has_code
> > boolean is true.
>
> Yes, it is simpler.
>
> Ok to commit ?

Yes, thanks.

Reply via email to