mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
internal: get rid of a call to slow O(N) visibility_of function
Instead of inferring module's declared visibility by looking at the scope of its parent, let's just remeber the declared visibility in the DefMap.
This commit is contained in:
parent
c8d19fedb8
commit
6f269708e8
4 changed files with 29 additions and 13 deletions
|
@ -430,8 +430,16 @@ impl Module {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn visibility(self, db: &dyn HirDatabase) -> Visibility {
|
||||
let def_map = self.id.def_map(db.upcast());
|
||||
let module_data = &def_map[self.id.local_id];
|
||||
module_data.visibility
|
||||
}
|
||||
|
||||
pub fn visibility_of(self, db: &dyn HirDatabase, def: &ModuleDef) -> Option<Visibility> {
|
||||
self.id.def_map(db.upcast())[self.id.local_id].scope.visibility_of((*def).into())
|
||||
let def_map = self.id.def_map(db.upcast());
|
||||
let module_data = &def_map[self.id.local_id];
|
||||
module_data.scope.visibility_of((*def).into())
|
||||
}
|
||||
|
||||
pub fn diagnostics(self, db: &dyn HirDatabase, acc: &mut Vec<AnyDiagnostic>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue