public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/96088] Range insertion into unordered_map is less effective than a loop with insertion
Date: Thu, 09 Jul 2020 08:31:31 +0000	[thread overview]
Message-ID: <bug-96088-4-Jr5W6oIJho@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96088-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96088

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to François Dumont from comment #1)
> I'll check if we can be smarter here. A nice improvement would be to change
> std::hash<std::string> operator signature to:
> 
>       size_t
>       operator()(const string_view& __str) const noexcept
> 
> but that's a Standard modification.

Or use unordered_map<string, int, hash<string_view>, equal_to<>> which should
perform better.

We haven't implemented http://wg21.link/p0919r3 and http://wg21.link/p1690r1
yet, I wonder if those would help, especially if we make the internal helpers
available pre-C++20. That could allow the range insertion to use the
heteregenous lookup, to avoid creating temporaries. I'm not sure if that would
be conforming though. Heterogeneous lookup is observably different, and not
conforming in C++17.

Adding hash<string>::operator()(string_view) is an interesting idea for the
standard though.

  parent reply	other threads:[~2020-07-09  8:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-06 18:37 [Bug libstdc++/96088] New: " antoshkka at gmail dot com
2020-07-09  6:23 ` [Bug libstdc++/96088] " fdumont at gcc dot gnu.org
2020-07-09  8:31 ` redi at gcc dot gnu.org [this message]
2020-07-09 10:50 ` glisse at gcc dot gnu.org
2020-07-09 14:46 ` redi at gcc dot gnu.org
2020-08-04 17:36 ` fdumont at gcc dot gnu.org
2021-05-25 19:27 ` fdumont at gcc dot gnu.org
2021-06-02 12:33 ` cvs-commit at gcc dot gnu.org

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=bug-96088-4-Jr5W6oIJho@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).