public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: "libstdc++@gcc.gnu.org" <libstdc++@gcc.gnu.org>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Enhance unordered container merge
Date: Sun, 14 Nov 2021 23:25:32 +0000	[thread overview]
Message-ID: <CAH6eHdTh1Ja0OtaK_Yo-5rPw6hHAfMa8qR0hxsJi_2CWLmgVMQ@mail.gmail.com> (raw)
In-Reply-To: <fd621d0f-b217-97cc-3428-e3a709a4f259@gmail.com>

On Sun, 14 Nov 2021 at 13:31, François Dumont via Libstdc++
<libstdc++@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.

  reply	other threads:[~2021-11-14 23:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-14 13:29 François Dumont
2021-11-14 23:25 ` Jonathan Wakely [this message]
2021-11-15  6:00   ` François Dumont
2021-11-15  9:10     ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdTh1Ja0OtaK_Yo-5rPw6hHAfMa8qR0hxsJi_2CWLmgVMQ@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=frs.dumont@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).