From ae614b8a3d7866764bfea6f30605f90268db572b Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Tue, 22 Oct 2024 08:01:16 -0400 Subject: [PATCH] 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 --- gcc/cp/pt.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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) -- 2.47.2