Skip to content
Snippets Groups Projects
Commit 5dad738c authored by Jason Merrill's avatar Jason Merrill
Browse files

c++: record template specialization hash


A lot of compile time of template-heavy code is spent in re-hashing
hashtable elements upon expansion.  The following records the hash in the
hash element.  This speeds up C++20 compilation of stdc++.h by about 25% for
about a 0.1% increase in memory usage.

With the hash value in the entry, we don't need to pass it separately to the
find functions.

Adding default arguments to the spec and hash fields simplifies spec_entry
initialization and avoids problems from hash starting with an indeterminate
value.

gcc/cp/ChangeLog:

	* cp-tree.h (spec_entry::hash): New member.
	* pt.cc (spec_hasher::hash): Set it and return it.
	(maybe_process_partial_specialization): Clear it when
	changing tmpl/args.
	(lookup_template_class): Likewise, don't pass hash to find.
	(retrieve_specialization): Set it, don't pass hash to find.
	(register_specialization): Don't pass hash to find.
	(reregister_specialization): Likewise.
	(match_mergeable_specialization): Likewise.
	(add_mergeable_specialization): Likewise.

Co-authored-by: default avatarRichard Biener <rguenther@suse.de>
parent e175fb38
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment