{"id":2226200,"url":"http://patchwork.ozlabs.org/api/patches/2226200/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.1@forge-stage.sourceware.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.1@forge-stage.sourceware.org>","list_archive_url":null,"date":"2026-04-22T10:25:10","name":"[v1,01/12] libstdc++: Refactor _Hashtable::operator=(initializer_list<value_type>)","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"3d3b493b246e00dcda3bdedf79796f3f8ada8899","submitter":{"id":93210,"url":"http://patchwork.ozlabs.org/api/people/93210/?format=json","name":"Jonathan Wakely via Sourceware Forge","email":"forge-bot+redi@forge-stage.sourceware.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.1@forge-stage.sourceware.org/mbox/","series":[{"id":500966,"url":"http://patchwork.ozlabs.org/api/series/500966/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500966","date":"2026-04-22T10:25:11","name":"WIP: libstdc++: Refactor hash table code","version":1,"mbox":"http://patchwork.ozlabs.org/series/500966/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226200/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226200/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org","sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org","server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0wjZ0nqSz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 20:40:34 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DA95F42FA061\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 10:40:31 +0000 (GMT)","from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id F173C4BBCDA8\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:26:14 +0000 (GMT)","from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id B4AD5405A0\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:26:14 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org DA95F42FA061","OpenDKIM Filter v2.11.0 sourceware.org F173C4BBCDA8"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org F173C4BBCDA8","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org F173C4BBCDA8","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776853575; cv=none;\n b=bLXpy/mIsh/+a8ycDKgwslBHX7UXBGncsMZr2MnQ9Xz63keZFoiucs4yjuNOBv38HH7Fn2WWWKsf6nSXiCTfEcN434EFLGcBXZnhPu2rP0gBSZtsW9a2pud8dpuzXhXkvtgqHrUyEYCsQOzkopmr16RAAcuMDNELgoz6xAbHLo4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776853575; c=relaxed/simple;\n bh=FmkiR5HFGdME+YkEtYzOaGKmp7X5iN3rd60FZgM3++E=;\n h=From:Date:Subject:MIME-Version:To:Message-ID;\n b=xtR8FJF/BHk/OKA+Hoi/LAiLKMsYiV/VXQ7W2VCbwi3PBkbxrGD7Y1356UI07BmCXqjco9HZTPDRTi2L9E3Qwgca4nmGsc8dxiqPhljgXy9I/OOmwHv1MCu5fN9rWsEo/H151oo1ZJ/37RE5tYWIefC4aM8Dnoit2gjvecyrj0w=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"Jonathan Wakely via Sourceware Forge\n <forge-bot+redi@forge-stage.sourceware.org>","Date":"Wed, 22 Apr 2026 10:25:10 +0000","Subject":"[PATCH v1 01/12] libstdc++: Refactor\n _Hashtable::operator=(initializer_list<value_type>)","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>","Message-ID":"\n <bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.1@forge-stage.sourceware.org>","X-Mailer":"batrachomyomachia","X-Requested-Reviewer":"fdumont","X-Pull-Request-Organization":"gcc","X-Pull-Request-Repository":"gcc-TEST","X-Pull-Request":"https://forge.sourceware.org/gcc/gcc-TEST/pulls/15","References":"\n <bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.0@forge-stage.sourceware.org>","In-Reply-To":"\n <bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.0@forge-stage.sourceware.org>","X-Patch-URL":"\n https://forge.sourceware.org/redi/gcc/commit/cf22f3a5d3359204c9d48de8e83c20903f158592","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Reply-To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>, redi@gcc.gnu.org","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"From: Jonathan Wakely <jwakely@redhat.com>\n\nThis replaces a call to _M_insert_range with open coding the loop. This\nwill allow removing the node generator parameter from _M_insert_range in\na later commit.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/hashtable.h (operator=(initializer_list)):\n\tRefactor to not use _M_insert_range.\n\nReviewed-by: François Dumont <fdumont@gcc.gnu.org>\n---\n libstdc++-v3/include/bits/hashtable.h | 35 ++++++++++++++++++++++++---\n 1 file changed, 32 insertions(+), 3 deletions(-)","diff":"diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h\nindex b36142b358a7..872fcac22d09 100644\n--- a/libstdc++-v3/include/bits/hashtable.h\n+++ b/libstdc++-v3/include/bits/hashtable.h\n@@ -610,6 +610,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \treturn *this;\n       }\n \n+#pragma GCC diagnostic push\n+#pragma GCC diagnostic ignored \"-Wc++17-extensions\" // if constexpr\n       _Hashtable&\n       operator=(initializer_list<value_type> __l)\n       {\n@@ -617,16 +619,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t_M_before_begin._M_nxt = nullptr;\n \tclear();\n \n-\t// We consider that all elements of __l are going to be inserted.\n+\t// We assume that all elements of __l are likely to be inserted.\n \tauto __l_bkt_count = _M_rehash_policy._M_bkt_for_elements(__l.size());\n \n-\t// Do not shrink to keep potential user reservation.\n+\t// Excess buckets might have been intentionally reserved by the user,\n+\t// so rehash if we need to grow, but don't shrink.\n \tif (_M_bucket_count < __l_bkt_count)\n \t  rehash(__l_bkt_count);\n \n-\tthis->_M_insert_range(__l.begin(), __l.end(), __roan, __unique_keys{});\n+\t_ExtractKey __ex;\n+\tfor (auto& __e : __l)\n+\t  {\n+\t    const key_type& __k = __ex(__e);\n+\n+\t    if constexpr (__unique_keys::value)\n+\t      if (this->size() <= __small_size_threshold())\n+\t\t{\n+\t\t  auto __it = _M_begin();\n+\t\t  for (; __it; __it = __it->_M_next())\n+\t\t    if (this->_M_key_equals(__k, *__it))\n+\t\t      break;\n+\t\t  if (__it)\n+\t\t    continue; // Found existing element with equivalent key\n+\t\t}\n+\n+\t    __hash_code __code = this->_M_hash_code(__k);\n+\t    size_type __bkt = _M_bucket_index(__code);\n+\n+\t    if constexpr (__unique_keys::value)\n+\t      if (_M_find_node(__bkt, __k, __code))\n+\t\tcontinue; // Found existing element with equivalent key\n+\n+\t    _M_insert_unique_node(__bkt, __code, __roan(__e));\n+\t  }\n+\n \treturn *this;\n       }\n+#pragma GCC diagnostic pop\n \n       ~_Hashtable() noexcept;\n \n","prefixes":["v1","01/12"]}