Handle DefPath hashing centrally as part of DefPathTable (+ save work during SVH calculation) #41056
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In almost all cases where we construct a
DefPath
, we just hash it and throw it away again immediately.With this PR, the compiler will immediately compute and store the hash for each
DefPath
as it is allocated. This way weDefPath
hash caching (e.g. theDefPathHashes
),Vec
for holding theDefPath
(although I'm always surprised how little these small, dynamic allocations seem to hurt performance), andDefPath
prefixes over and over again.That last part is because we construct the hash for
prefix::foo
by hashing(hash(prefix), foo)
instead of hashing every component of prefix.The last commit of this PR is pretty neat, I think:
r? @nikomatsakis
This PR depends on #40878 to be merged first (you can ignore the first commit for reviewing, that's just #40878).