aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-04 02:26:16 +0100
committerJonas Schievink <[email protected]>2021-04-04 02:26:16 +0100
commit1da6d0bed9d8ead94a88db343efe2a4e91644be1 (patch)
tree79b167d49d9941ce2e6676e7b8708448a81e79c8 /crates/hir_def/src/body.rs
parent4c8ee9a53190917f9171a3272c8061d926c2fcbe (diff)
Add `Body::shrink_to_fit`
Diffstat (limited to 'crates/hir_def/src/body.rs')
-rw-r--r--crates/hir_def/src/body.rs12
1 files changed, 11 insertions, 1 deletions
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 {
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
333impl Index<ExprId> for Body { 343impl Index<ExprId> for Body {