diff mbox series

c++: redundant hashing in register_specialization

Message ID 20241017220419.443922-1-ppalka@redhat.com
State New
Headers show
Series c++: redundant hashing in register_specialization | expand

Commit Message

Patrick Palka Oct. 17, 2024, 10:04 p.m. UTC
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look
OK for trunk?

-- >8 --

After r15-4050-g5dad738c1dd164 register_specialization needs to set
elt.hash to the (maybe) precomputed hash in order to avoid redundantly
rehashing.

gcc/cp/ChangeLog:

	* pt.cc (register_specialization): Set elt.hash.
---
 gcc/cp/pt.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 8b183a139d7..ec4313090bd 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -1545,9 +1545,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)