mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
Flatten SourceToDefCache structure
This commit is contained in:
parent
c90ecc5c26
commit
0336e9b25f
@ -106,7 +106,7 @@ use syntax::{
|
|||||||
|
|
||||||
use crate::{db::HirDatabase, InFile};
|
use crate::{db::HirDatabase, InFile};
|
||||||
|
|
||||||
pub(super) type SourceToDefCache = FxHashMap<ChildContainer, FxHashMap<HirFileId, DynMap>>;
|
pub(super) type SourceToDefCache = FxHashMap<(ChildContainer, HirFileId), DynMap>;
|
||||||
|
|
||||||
pub(super) struct SourceToDefCtx<'a, 'b> {
|
pub(super) struct SourceToDefCtx<'a, 'b> {
|
||||||
pub(super) db: &'b dyn HirDatabase,
|
pub(super) db: &'b dyn HirDatabase,
|
||||||
@ -257,8 +257,9 @@ impl SourceToDefCtx<'_, '_> {
|
|||||||
|
|
||||||
fn cache_for(&mut self, container: ChildContainer, file_id: HirFileId) -> &DynMap {
|
fn cache_for(&mut self, container: ChildContainer, file_id: HirFileId) -> &DynMap {
|
||||||
let db = self.db;
|
let db = self.db;
|
||||||
let dyn_maps = self.cache.entry(container).or_default();
|
self.cache
|
||||||
dyn_maps.entry(file_id).or_insert_with(|| container.child_by_source(db, file_id))
|
.entry((container, file_id))
|
||||||
|
.or_insert_with(|| container.child_by_source(db, file_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn type_param_to_def(&mut self, src: InFile<ast::TypeParam>) -> Option<TypeParamId> {
|
pub(super) fn type_param_to_def(&mut self, src: InFile<ast::TypeParam>) -> Option<TypeParamId> {
|
||||||
|
Loading…
Reference in New Issue
Block a user