From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1994B386196F; Thu, 9 Jul 2020 08:31:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1994B386196F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594283492; bh=aXQEbNMlPNtBGjSQ5Ix/YsdKHJOSyJvMBPQNoDlDflE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=imz606cm8h+9I+H/xMvvDIhJZs3jWmGYHs4wWHLkdnpcfM3ij7O5bxNj8NfymaIPy /O7rH0IVzIeRo+ieFd8AyS0lXO5w++BBzqsS1bODNbQhQ5W/UbdSN/3wQq+gGPcAWY lNnoUV5h0GWkzwy+LztMrdOra/s/WgWqfm3WBZ8s= From: "redi at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jul 2020 08:31:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96088 --- Comment #2 from Jonathan Wakely --- (In reply to Fran=C3=A7ois Dumont from comment #1) > I'll check if we can be smarter here. A nice improvement would be to chan= ge > std::hash operator signature to: >=20 > size_t > operator()(const string_view& __str) const noexcept >=20 > but that's a Standard modification. Or use unordered_map, equal_to<>> which shou= ld 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 helpe= rs 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 wo= uld be conforming though. Heterogeneous lookup is observably different, and not conforming in C++17. Adding hash::operator()(string_view) is an interesting idea for the standard though.=