Skip to content

Commit 994df3d

Browse files
committed
Auto merge of rust-lang#15586 - Veykril:shrink, r=Veykril
shrink_to_fit body source map
2 parents a3cfb45 + cfcef69 commit 994df3d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

crates/hir-def/src/body.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ impl Body {
166166
};
167167
let module = def.module(db);
168168
let expander = Expander::new(db, file_id, module);
169-
let (mut body, source_map) =
169+
let (mut body, mut source_map) =
170170
Body::new(db, def, expander, params, body, module.krate, is_async_fn);
171171
body.shrink_to_fit();
172+
source_map.shrink_to_fit();
172173

173174
(Arc::new(body), Arc::new(source_map))
174175
}
@@ -390,4 +391,29 @@ impl BodySourceMap {
390391
pub fn diagnostics(&self) -> &[BodyDiagnostic] {
391392
&self.diagnostics
392393
}
394+
395+
fn shrink_to_fit(&mut self) {
396+
let Self {
397+
expr_map,
398+
expr_map_back,
399+
pat_map,
400+
pat_map_back,
401+
label_map,
402+
label_map_back,
403+
field_map_back,
404+
pat_field_map_back,
405+
expansions,
406+
diagnostics,
407+
} = self;
408+
expr_map.shrink_to_fit();
409+
expr_map_back.shrink_to_fit();
410+
pat_map.shrink_to_fit();
411+
pat_map_back.shrink_to_fit();
412+
label_map.shrink_to_fit();
413+
label_map_back.shrink_to_fit();
414+
field_map_back.shrink_to_fit();
415+
pat_field_map_back.shrink_to_fit();
416+
expansions.shrink_to_fit();
417+
diagnostics.shrink_to_fit();
418+
}
393419
}

crates/hir-def/src/import_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> FxIndexMap<ItemIn
175175
}
176176
}
177177
}
178-
178+
map.shrink_to_fit();
179179
map
180180
}
181181

0 commit comments

Comments
 (0)