From 1da6d0bed9d8ead94a88db343efe2a4e91644be1 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 4 Apr 2021 03:26:16 +0200 Subject: Add `Body::shrink_to_fit` --- crates/hir_def/src/body.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/hir_def/src') diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index ad3d5afbe..a5fc652a7 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs @@ -302,7 +302,8 @@ impl Body { } }; let expander = Expander::new(db, file_id, module); - let (body, source_map) = Body::new(db, expander, params, body); + let (mut body, source_map) = Body::new(db, expander, params, body); + body.shrink_to_fit(); (Arc::new(body), Arc::new(source_map)) } @@ -328,6 +329,15 @@ impl Body { ) -> (Body, BodySourceMap) { lower::lower(db, expander, params, body) } + + fn shrink_to_fit(&mut self) { + let Self { _c: _, body_expr: _, block_scopes, exprs, labels, params, pats } = self; + block_scopes.shrink_to_fit(); + exprs.shrink_to_fit(); + labels.shrink_to_fit(); + params.shrink_to_fit(); + pats.shrink_to_fit(); + } } impl Index for Body { -- cgit v1.2.3