diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2023-09-09 14:40:56 +0200 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2023-09-09 14:40:56 +0200 |
| commit | cfcef69072aa87ecab6f127092972ccab201b7ee (patch) | |
| tree | 7f9a757d7c24ddc02fc9830835be46415d5ca5bd | |
| parent | 8f5fee4a5aab72399da267fca256090c03c55ff6 (diff) | |
| download | rust-cfcef69072aa87ecab6f127092972ccab201b7ee.tar.gz rust-cfcef69072aa87ecab6f127092972ccab201b7ee.zip | |
shrink_to_fit body source map
| -rw-r--r-- | crates/hir-def/src/body.rs | 28 | ||||
| -rw-r--r-- | crates/hir-def/src/import_map.rs | 2 |
2 files changed, 28 insertions, 2 deletions
diff --git a/crates/hir-def/src/body.rs b/crates/hir-def/src/body.rs index 26fd58c0a40..c0baf6011f7 100644 --- a/crates/hir-def/src/body.rs +++ b/crates/hir-def/src/body.rs @@ -166,9 +166,10 @@ impl Body { }; let module = def.module(db); let expander = Expander::new(db, file_id, module); - let (mut body, source_map) = + let (mut body, mut source_map) = Body::new(db, def, expander, params, body, module.krate, is_async_fn); body.shrink_to_fit(); + source_map.shrink_to_fit(); (Arc::new(body), Arc::new(source_map)) } @@ -390,4 +391,29 @@ impl BodySourceMap { pub fn diagnostics(&self) -> &[BodyDiagnostic] { &self.diagnostics } + + fn shrink_to_fit(&mut self) { + let Self { + expr_map, + expr_map_back, + pat_map, + pat_map_back, + label_map, + label_map_back, + field_map_back, + pat_field_map_back, + expansions, + diagnostics, + } = self; + expr_map.shrink_to_fit(); + expr_map_back.shrink_to_fit(); + pat_map.shrink_to_fit(); + pat_map_back.shrink_to_fit(); + label_map.shrink_to_fit(); + label_map_back.shrink_to_fit(); + field_map_back.shrink_to_fit(); + pat_field_map_back.shrink_to_fit(); + expansions.shrink_to_fit(); + diagnostics.shrink_to_fit(); + } } diff --git a/crates/hir-def/src/import_map.rs b/crates/hir-def/src/import_map.rs index c961d7d86d8..721da29ce81 100644 --- a/crates/hir-def/src/import_map.rs +++ b/crates/hir-def/src/import_map.rs @@ -175,7 +175,7 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> FxIndexMap<ItemIn } } } - + map.shrink_to_fit(); map } |
