Skip to content

Commit c9bcbf9

Browse files
Merge #8324
8324: Add `Body::shrink_to_fit` r=jonas-schievink a=jonas-schievink Saves ~15 MB bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents 3ea5ea1 + 1da6d0b commit c9bcbf9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/hir_def/src/body.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ impl Body {
302302
}
303303
};
304304
let expander = Expander::new(db, file_id, module);
305-
let (body, source_map) = Body::new(db, expander, params, body);
305+
let (mut body, source_map) = Body::new(db, expander, params, body);
306+
body.shrink_to_fit();
306307
(Arc::new(body), Arc::new(source_map))
307308
}
308309

@@ -328,6 +329,15 @@ impl Body {
328329
) -> (Body, BodySourceMap) {
329330
lower::lower(db, expander, params, body)
330331
}
332+
333+
fn shrink_to_fit(&mut self) {
334+
let Self { _c: _, body_expr: _, block_scopes, exprs, labels, params, pats } = self;
335+
block_scopes.shrink_to_fit();
336+
exprs.shrink_to_fit();
337+
labels.shrink_to_fit();
338+
params.shrink_to_fit();
339+
pats.shrink_to_fit();
340+
}
331341
}
332342

333343
impl Index<ExprId> for Body {

0 commit comments

Comments
 (0)