aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
authorAlexandru Macovei <[email protected]>2021-03-30 21:06:57 +0100
committerAlexandru Macovei <[email protected]>2021-04-06 14:01:31 +0100
commitfb1f544e2479addd5957688e297ea04ddf0cf249 (patch)
treecad7e5fce89b5b42d46ea5c9fe6f5bc12ed7c03e /crates/hir_ty/src
parent4bc8a018302d53951ae855ba57d07095a16ef182 (diff)
Use Box'es to reduce size of hir_def::expr::Expr from 128 to 72 bytes (on 64bit systems)
Rationale: only a minority of variants used almost half the size. By keeping large members (especially in Option) behind a box the memory cost is only payed when the large variants are needed. This reduces the size Vec<Expr> needs to allocate.
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/infer/expr.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index ff564106b..2fcc7c549 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -317,7 +317,13 @@ impl<'a> InferenceContext<'a> {
317 self.normalize_associated_types_in(ret_ty) 317 self.normalize_associated_types_in(ret_ty)
318 } 318 }
319 Expr::MethodCall { receiver, args, method_name, generic_args } => self 319 Expr::MethodCall { receiver, args, method_name, generic_args } => self
320 .infer_method_call(tgt_expr, *receiver, &args, &method_name, generic_args.as_ref()), 320 .infer_method_call(
321 tgt_expr,
322 *receiver,
323 &args,
324 &method_name,
325 generic_args.as_deref(),
326 ),
321 Expr::Match { expr, arms } => { 327 Expr::Match { expr, arms } => {
322 let input_ty = self.infer_expr(*expr, &Expectation::none()); 328 let input_ty = self.infer_expr(*expr, &Expectation::none());
323 329
@@ -398,7 +404,7 @@ impl<'a> InferenceContext<'a> {
398 TyKind::Never.intern(&Interner) 404 TyKind::Never.intern(&Interner)
399 } 405 }
400 Expr::RecordLit { path, fields, spread } => { 406 Expr::RecordLit { path, fields, spread } => {
401 let (ty, def_id) = self.resolve_variant(path.as_ref()); 407 let (ty, def_id) = self.resolve_variant(path.as_deref());
402 if let Some(variant) = def_id { 408 if let Some(variant) = def_id {
403 self.write_variant_resolution(tgt_expr.into(), variant); 409 self.write_variant_resolution(tgt_expr.into(), variant);
404 } 410 }