]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: optimize push_to_top_level [PR64500]
authorJason Merrill <jason@redhat.com>
Mon, 24 Mar 2025 19:28:04 +0000 (15:28 -0400)
committerJason Merrill <jason@redhat.com>
Sat, 29 Mar 2025 12:46:23 +0000 (08:46 -0400)
commit5ac4be28822a4e6f506a69096f92d4675a7d5a72
tree3cc651ae7c0810ac0a77ae87041d573c37528c09
parent39bea4b71f0ee45756e68b9e74002b0ca25606e4
c++: optimize push_to_top_level [PR64500]

Profiling showed that the loop to save away IDENTIFIER_BINDINGs from open
binding levels was taking 5% of total compilation time in the PR116285
testcase.  This turned out to be because we were unnecessarily trying to do
this for namespaces, whose bindings are found through
DECL_NAMESPACE_BINDINGS, not IDENTIFIER_BINDING.

As a result we would frequently loop through everything in std::, checking
whether it needs to be stored, and never storing anything.

This change actually appears to speed up compilation for the PR116285
testcase by ~20%.

The replaced comments referred either to long-replaced handling of classes
and templates, or to wanting b to point to :: when the loop exits.

PR c++/64500
PR c++/116285

gcc/cp/ChangeLog:

* name-lookup.cc (push_to_top_level): Don't try to store_bindings
for namespace levels.
gcc/cp/name-lookup.cc