mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
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.
This commit is contained in:
parent
4bc8a01830
commit
fb1f544e24
3 changed files with 22 additions and 12 deletions
|
@ -317,7 +317,13 @@ impl<'a> InferenceContext<'a> {
|
|||
self.normalize_associated_types_in(ret_ty)
|
||||
}
|
||||
Expr::MethodCall { receiver, args, method_name, generic_args } => self
|
||||
.infer_method_call(tgt_expr, *receiver, &args, &method_name, generic_args.as_ref()),
|
||||
.infer_method_call(
|
||||
tgt_expr,
|
||||
*receiver,
|
||||
&args,
|
||||
&method_name,
|
||||
generic_args.as_deref(),
|
||||
),
|
||||
Expr::Match { expr, arms } => {
|
||||
let input_ty = self.infer_expr(*expr, &Expectation::none());
|
||||
|
||||
|
@ -398,7 +404,7 @@ impl<'a> InferenceContext<'a> {
|
|||
TyKind::Never.intern(&Interner)
|
||||
}
|
||||
Expr::RecordLit { path, fields, spread } => {
|
||||
let (ty, def_id) = self.resolve_variant(path.as_ref());
|
||||
let (ty, def_id) = self.resolve_variant(path.as_deref());
|
||||
if let Some(variant) = def_id {
|
||||
self.write_variant_resolution(tgt_expr.into(), variant);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue