Skip to content

Commit 0336e9b

Browse files
committed
Flatten SourceToDefCache structure
1 parent c90ecc5 commit 0336e9b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/hir/src/semantics/source_to_def.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ use syntax::{
106106

107107
use crate::{db::HirDatabase, InFile};
108108

109-
pub(super) type SourceToDefCache = FxHashMap<ChildContainer, FxHashMap<HirFileId, DynMap>>;
109+
pub(super) type SourceToDefCache = FxHashMap<(ChildContainer, HirFileId), DynMap>;
110110

111111
pub(super) struct SourceToDefCtx<'a, 'b> {
112112
pub(super) db: &'b dyn HirDatabase,
@@ -257,8 +257,9 @@ impl SourceToDefCtx<'_, '_> {
257257

258258
fn cache_for(&mut self, container: ChildContainer, file_id: HirFileId) -> &DynMap {
259259
let db = self.db;
260-
let dyn_maps = self.cache.entry(container).or_default();
261-
dyn_maps.entry(file_id).or_insert_with(|| container.child_by_source(db, file_id))
260+
self.cache
261+
.entry((container, file_id))
262+
.or_insert_with(|| container.child_by_source(db, file_id))
262263
}
263264

264265
pub(super) fn type_param_to_def(&mut self, src: InFile<ast::TypeParam>) -> Option<TypeParamId> {

0 commit comments

Comments
 (0)