-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler code cleanup: replace metas: HashMap with IndexVec #46876
Comments
So is it just replacing the type with?
If sow what is the equivalent for insert? rust/src/librustc_metadata/cstore.rs Line 118 in 970c613
|
Should be as simple as that |
The only way I am seeing to add to an IndexVec is to push to the end at index == len
But the hashmap uses the ability to insert at an arbitrary index: rust/src/librustc_metadata/cstore.rs Line 118 in 970c613
So I don't quite see how to make the conversion. |
@Eh2406 from my quick skimming, rust/src/librustc_metadata/creader.rs Line 278 in 691f022
The So I would suggest removing |
BTW if one really did need to support overwriting for arbitrary |
Maybe you want an |
That's not 100% correct. Crate numbers are assigned in preorder - if a crate (say But it's ok to use an |
You are right. I overlooked the fact that we 1. first increment the crate num (reserving the number, like for |
Ok, what is the best incantation to test this locally? In the meantime I will open a pr. |
CStore switch FxHashMap to IndexVec This is a first attempt to fix #46876.
While investigating the root cause(s) of #46112 and discussing (in the
#rustc
IRC chat room) the use of a hashmap mapping crate-numbers to crate-metadata, @eddyb at some point exclaimed "why is that not anIndexVec
?"One word: Legacy. Big time: the
metas
field has been a hashmap ever sincemetadata::cstore
was introduced, 6.5 years ago in b23ecd4 (relevant line in diff)It should be a useful (and hopefully simple?) exercise to replace the hashmap that is now there with an
IndexVec
.The text was updated successfully, but these errors were encountered: