diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-04 02:27:14 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-04 02:27:14 +0100 |
commit | c9bcbf9a43eb0bf1a5255f704080305e568f0a36 (patch) | |
tree | 419589eddb34fab7b627e2d4ea11fd6cced6f5cf /crates | |
parent | 3ea5ea1324310af07a8bb04fb3314b087d7153c9 (diff) | |
parent | 1da6d0bed9d8ead94a88db343efe2a4e91644be1 (diff) |
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]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_def/src/body.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs index 99d98b17e..96b959967 100644 --- a/crates/hir_def/src/body.rs +++ b/crates/hir_def/src/body.rs | |||
@@ -302,7 +302,8 @@ impl Body { | |||
302 | } | 302 | } |
303 | }; | 303 | }; |
304 | let expander = Expander::new(db, file_id, module); | 304 | 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(); | ||
306 | (Arc::new(body), Arc::new(source_map)) | 307 | (Arc::new(body), Arc::new(source_map)) |
307 | } | 308 | } |
308 | 309 | ||
@@ -328,6 +329,15 @@ impl Body { | |||
328 | ) -> (Body, BodySourceMap) { | 329 | ) -> (Body, BodySourceMap) { |
329 | lower::lower(db, expander, params, body) | 330 | lower::lower(db, expander, params, body) |
330 | } | 331 | } |
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 | } | ||
331 | } | 341 | } |
332 | 342 | ||
333 | impl Index<ExprId> for Body { | 343 | impl Index<ExprId> for Body { |