perf: Provide better incrementality for modules#22322
Conversation
| pub block: Option<BlockId>, | ||
| /// The parent module of this module, or `None` if this is the root module inside the def | ||
| /// map (including for block def maps). | ||
| pub containing_module_inside_def_map: Option<ModuleIdLt<'db>>, |
There was a problem hiding this comment.
I wanted to be explicit. But I can change that, if you want.
|
|
||
| pub fn name(self, db: &dyn DefDatabase) -> Option<Name> { | ||
| let def_map = self.def_map(db); | ||
| let parent = def_map[self].parent?; |
There was a problem hiding this comment.
Do we need the parent field on the ModuleData now or can we discard this in favor of the IDs field?
There was a problem hiding this comment.
It's still used in one place but we can derive it from the module instead of the def map.
| /// map (including for block def maps). | ||
| pub containing_module_inside_def_map: Option<ModuleIdLt<'db>>, | ||
| /// The name of this module, or [`sym::__empty`] for the root module. | ||
| name_or_empty: Name, |
There was a problem hiding this comment.
Would also call this just name, keeping the doc comment.
There was a problem hiding this comment.
This will clash with the method (because Salsa generates a method), a frankly I'm happier with the current name. It removes any chances of mistake.
This comment has been minimized.
This comment has been minimized.
Previously module ID reuse was based on order of creation solely. Now we store the parent module and name, and so Salsa will reuse the ID for modules that have the same name and parent. This is important as many interned IDs contain modules, so if the module is invalidated they too are.
406af24 to
89920fb
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Previously module ID reuse was based on order of creation solely. Now we store the parent module and name, and so Salsa will reuse the ID for modules that have the same name and parent.
This is important as many interned IDs contain modules, so if the module is invalidated they too are.