Skip to content

Commit

Permalink
Auto merge of #15586 - Veykril:shrink, r=Veykril
Browse files Browse the repository at this point in the history
shrink_to_fit body source map
  • Loading branch information
bors committed Sep 9, 2023
2 parents a3cfb45 + cfcef69 commit 994df3d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 27 additions & 1 deletion crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion crates/hir-def/src/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> FxIndexMap<ItemIn
}
}
}

map.shrink_to_fit();
map
}

Expand Down

0 comments on commit 994df3d

Please sign in to comment.