From: Patrick Palka Date: Tue, 22 Oct 2024 12:01:16 +0000 (-0400) Subject: c++: redundant hashing in register_specialization X-Git-Tag: basepoints/gcc-16~5009 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ae614b8a3d7866764bfea6f30605f90268db572b;p=thirdparty%2Fgcc.git c++: redundant hashing in register_specialization After r15-4050-g5dad738c1dd164 register_specialization needs to set elt.hash to the (maybe) precomputed hash so that the lookup uses it rather than redundantly computing it from scratch. gcc/cp/ChangeLog: * pt.cc (register_specialization): Set elt.hash. Reviewed-by: Jason Merrill --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 0141c53b617c..b590c32345f6 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -1546,9 +1546,7 @@ register_specialization (tree spec, tree tmpl, tree args, bool is_friend, elt.tmpl = tmpl; elt.args = args; elt.spec = spec; - - if (hash == 0) - hash = spec_hasher::hash (&elt); + elt.hash = hash; spec_entry **slot = decl_specializations->find_slot (&elt, INSERT); if (*slot)