From 0336e9b25fec9e2dd9d951137c72ebfa24f774fd Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 16 Aug 2021 17:55:18 +0200 Subject: [PATCH] Flatten SourceToDefCache structure --- crates/hir/src/semantics/source_to_def.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/hir/src/semantics/source_to_def.rs b/crates/hir/src/semantics/source_to_def.rs index 4d4b26b8d86..773eab79315 100644 --- a/crates/hir/src/semantics/source_to_def.rs +++ b/crates/hir/src/semantics/source_to_def.rs @@ -106,7 +106,7 @@ use crate::{db::HirDatabase, InFile}; -pub(super) type SourceToDefCache = FxHashMap>; +pub(super) type SourceToDefCache = FxHashMap<(ChildContainer, HirFileId), DynMap>; pub(super) struct SourceToDefCtx<'a, 'b> { pub(super) db: &'b dyn HirDatabase, @@ -257,8 +257,9 @@ fn dyn_map(&mut self, src: InFile<&Ast>) -> Option<&DynM fn cache_for(&mut self, container: ChildContainer, file_id: HirFileId) -> &DynMap { let db = self.db; - let dyn_maps = self.cache.entry(container).or_default(); - dyn_maps.entry(file_id).or_insert_with(|| container.child_by_source(db, file_id)) + self.cache + .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) -> Option {