{"id":2226195,"url":"http://patchwork.ozlabs.org/api/patches/2226195/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhub8n5f78.gcc.gcc-TEST.redi.15.1.5@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.5@forge-stage.sourceware.org>","list_archive_url":null,"date":"2026-04-22T10:25:14","name":"[v1,05/12] libstdc++: Add _Hashtable::_M_assign for the common case","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b8976137a513f1a18337668d59be0d79083fb137","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.5@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/2226195/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226195/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 4g0wgK04WVz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 20:38:36 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id A6D2D4B7A1DB\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 10:38:34 +0000 (GMT)","from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id 5FD2C4BBCDD1\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:26:17 +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 EFA3C405A4\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 A6D2D4B7A1DB","OpenDKIM Filter v2.11.0 sourceware.org 5FD2C4BBCDD1"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 5FD2C4BBCDD1","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 5FD2C4BBCDD1","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776853577; cv=none;\n b=PPrD4Ce1OvagSyQqCoZ2aZIGzCsGWeDMZqF/APBxwdIxZBj8P7OPDCFjhHUzXm6akI+c8mv9fUa9OnYaxScFdiS86vYH18Ru2NEKwR/V54YWOaDeIGUpWHtjc/zWl1hR9JM3pbLMVLyCpnqXKDI34yOeVY/Hiwh5UAjVjmmrxWc=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776853577; c=relaxed/simple;\n bh=SLFg9RuXZkVFj0T1WlHOFwhDnLO0SArNWW0IKpASuvE=;\n h=From:Date:Subject:MIME-Version:To:Message-ID;\n b=JkIcqUEHTAwl/k6sga1hy0vbWER15nzLdhxukI5W0VDu2ERE5MPwb0SFCAX5ZsgCfgRFJKAKmZxx5leEqmcP6VKWOpVAaCEKyvh2dWrPFsgac6xSq0dopGHoQSApkKWxrVosJXyLSrXA3EzSl8aKRmcexGdqY8ornudVqhGht3U=","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:14 +0000","Subject":"[PATCH v1 05/12] libstdc++: Add _Hashtable::_M_assign for the common\n case","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.5@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/cab7898b3bbc383aff757f74c3f413bc92e99de3","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 adds a convenient _M_assign overload for the common case where the\nnode generator is the _AllocNode type. Only two places need to call\n_M_assign with a _ReuseOrAllocNode node generator, so all the other\ncalls to _M_assign can use the new overload instead of manually\nconstructing a node generator.\n\nThe _AllocNode::operator(Args&&...) function doesn't need to be a\nvariadic template. It is only ever called with a single argument of type\nconst value_type& or value_type&&, so could be simplified. That isn't\ndone in this commit.\n\nlibstdc++-v3/ChangeLog:\n\n\t* include/bits/hashtable.h (_Hashtable): Remove typedefs for\n\tnode generators.\n\t(_Hashtable::_M_assign(_Ht&&)): Add new overload.\n\t(_Hashtable::operator=(initializer_list<value_type>)): Add local\n\ttypedef for node generator.\n\t(_Hashtable::_M_assign_elements): Likewise.\n\t(_Hashtable::operator=(const _Hashtable&)): Use new _M_assign\n\toverload.\n\t(_Hashtable(const _Hashtable&)): Likewise.\n\t(_Hashtable(const _Hashtable&, const allocator_type&)):\n\tLikewise.\n\t(_Hashtable(_Hashtable&&, __node_alloc_type&&, false_type)):\n\tLikewise.\n\t* include/bits/hashtable_policy.h (_Insert): Remove typedef for\n\tnode generator.\n\nReviewed-by: François Dumont <fdumont@gcc.gnu.org>\n---\n libstdc++-v3/include/bits/hashtable.h        | 34 +++++++++++---------\n libstdc++-v3/include/bits/hashtable_policy.h |  1 -\n 2 files changed, 19 insertions(+), 16 deletions(-)","diff":"diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h\nindex 23484f711cc5..bf6eed7c1c69 100644\n--- a/libstdc++-v3/include/bits/hashtable.h\n+++ b/libstdc++-v3/include/bits/hashtable.h\n@@ -299,12 +299,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t\t\t\t\t    _Equal, _Hash, _RangeHash, _Unused,\n \t\t\t\t\t    _RehashPolicy, _Traits>;\n \n-      using __reuse_or_alloc_node_gen_t =\n-\t__detail::_ReuseOrAllocNode<__node_alloc_type>;\n-      using __alloc_node_gen_t =\n-\t__detail::_AllocNode<__node_alloc_type>;\n-      using __node_builder_t =\n-\t__detail::_NodeBuilder<_ExtractKey>;\n+      using __node_builder_t = __detail::_NodeBuilder<_ExtractKey>;\n \n       // Simple RAII type for managing a node containing an element\n       struct _Scoped_node\n@@ -480,6 +475,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \tvoid\n \t_M_assign_elements(_Ht&&);\n \n+      template<typename _Ht>\n+\tvoid\n+\t_M_assign(_Ht&& __ht)\n+\t{\n+\t  __detail::_AllocNode<__node_alloc_type> __alloc_node_gen(*this);\n+\t  _M_assign(std::forward<_Ht>(__ht), __alloc_node_gen);\n+\t}\n+\n       template<typename _Ht, typename _NodeGenerator>\n \tvoid\n \t_M_assign(_Ht&&, _NodeGenerator&);\n@@ -608,6 +611,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       _Hashtable&\n       operator=(initializer_list<value_type> __l)\n       {\n+\tusing __reuse_or_alloc_node_gen_t =\n+\t  __detail::_ReuseOrAllocNode<__node_alloc_type>;\n+\n \t__reuse_or_alloc_node_gen_t __roan(_M_begin(), *this);\n \t_M_before_begin._M_nxt = nullptr;\n \tclear();\n@@ -1308,10 +1314,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t      _M_bucket_count = __ht._M_bucket_count;\n \t      _M_element_count = __ht._M_element_count;\n \t      _M_rehash_policy = __ht._M_rehash_policy;\n-\t      __alloc_node_gen_t __alloc_node_gen(*this);\n \t      __try\n \t\t{\n-\t\t  _M_assign(__ht, __alloc_node_gen);\n+\t\t  _M_assign(__ht);\n \t\t}\n \t      __catch(...)\n \t\t{\n@@ -1340,6 +1345,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t\t _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::\n       _M_assign_elements(_Ht&& __ht)\n       {\n+\tusing __reuse_or_alloc_node_gen_t =\n+\t  __detail::_ReuseOrAllocNode<__node_alloc_type>;\n+\n \t__buckets_ptr __former_buckets = nullptr;\n \tstd::size_t __former_bucket_count = _M_bucket_count;\n \t__rehash_guard_t __rehash_guard(_M_rehash_policy);\n@@ -1517,8 +1525,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       _M_element_count(__ht._M_element_count),\n       _M_rehash_policy(__ht._M_rehash_policy)\n     {\n-      __alloc_node_gen_t __alloc_node_gen(*this);\n-      _M_assign(__ht, __alloc_node_gen);\n+      _M_assign(__ht);\n     }\n \n   template<typename _Key, typename _Value, typename _Alloc,\n@@ -1572,8 +1579,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n       _M_element_count(__ht._M_element_count),\n       _M_rehash_policy(__ht._M_rehash_policy)\n     {\n-      __alloc_node_gen_t __alloc_node_gen(*this);\n-      _M_assign(__ht, __alloc_node_gen);\n+      _M_assign(__ht);\n     }\n \n   template<typename _Key, typename _Value, typename _Alloc,\n@@ -1612,12 +1618,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION\n \t}\n       else\n \t{\n-\t  __alloc_node_gen_t __alloc_gen(*this);\n-\n \t  using _Fwd_Ht = __conditional_t<\n \t    __move_if_noexcept_cond<value_type>::value,\n \t    const _Hashtable&, _Hashtable&&>;\n-\t  _M_assign(std::forward<_Fwd_Ht>(__ht), __alloc_gen);\n+\t  _M_assign(std::forward<_Fwd_Ht>(__ht));\n \t  __ht.clear();\n \t}\n     }\ndiff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h\nindex caedb0258ef4..cf97e571c1e2 100644\n--- a/libstdc++-v3/include/bits/hashtable_policy.h\n+++ b/libstdc++-v3/include/bits/hashtable_policy.h\n@@ -978,7 +978,6 @@ namespace __detail\n \n       using __unique_keys = typename _Traits::__unique_keys;\n       using __node_alloc_type = typename __hashtable_alloc::__node_alloc_type;\n-      using __node_gen_type = _AllocNode<__node_alloc_type>;\n \n       [[__gnu__::__always_inline__]]\n       __hashtable&\n","prefixes":["v1","05/12"]}