Use ThinVec
in ast::ExprKind::Match
.
This commit is contained in:
parent
912b825002
commit
549f1c60af
8 changed files with 9 additions and 9 deletions
|
@ -71,7 +71,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> Bl
|
|||
let eq_arm = cx.arm(span, cx.pat_path(span, equal_path.clone()), expr1);
|
||||
let neq_arm =
|
||||
cx.arm(span, cx.pat_ident(span, test_id), cx.expr_ident(span, test_id));
|
||||
cx.expr_match(span, expr2, vec![eq_arm, neq_arm])
|
||||
cx.expr_match(span, expr2, thin_vec![eq_arm, neq_arm])
|
||||
}
|
||||
CsFold::Fieldless => cx.expr_path(equal_path.clone()),
|
||||
},
|
||||
|
|
|
@ -143,7 +143,7 @@ fn cs_partial_cmp(
|
|||
cx.arm(span, cx.pat_some(span, cx.pat_path(span, equal_path.clone())), expr1);
|
||||
let neq_arm =
|
||||
cx.arm(span, cx.pat_ident(span, test_id), cx.expr_ident(span, test_id));
|
||||
cx.expr_match(span, expr2, vec![eq_arm, neq_arm])
|
||||
cx.expr_match(span, expr2, thin_vec![eq_arm, neq_arm])
|
||||
}
|
||||
}
|
||||
CsFold::Fieldless => cx.expr_some(span, cx.expr_path(equal_path.clone())),
|
||||
|
|
|
@ -234,7 +234,7 @@ fn show_fieldless_enum(
|
|||
};
|
||||
cx.arm(span, pat, cx.expr_str(span, v.ident.name))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
.collect::<ThinVec<_>>();
|
||||
let name = cx.expr_match(span, cx.expr_self(span), arms);
|
||||
let fn_path_write_str = cx.std_path(&[sym::fmt, sym::Formatter, sym::write_str]);
|
||||
BlockOrExpr::new_expr(cx.expr_call_global(span, fn_path_write_str, thin_vec![fmt, name]))
|
||||
|
|
|
@ -123,7 +123,7 @@ fn decodable_substructure(
|
|||
StaticEnum(_, fields) => {
|
||||
let variant = Ident::new(sym::i, trait_span);
|
||||
|
||||
let mut arms = Vec::with_capacity(fields.len() + 1);
|
||||
let mut arms = ThinVec::with_capacity(fields.len() + 1);
|
||||
let mut variants = ThinVec::with_capacity(fields.len());
|
||||
|
||||
let fn_read_enum_variant_arg_path: Vec<_> =
|
||||
|
|
|
@ -1247,7 +1247,7 @@ impl<'a> MethodDef<'a> {
|
|||
// (Variant2, Variant2, ...) => Body2
|
||||
// ...
|
||||
// where each tuple has length = selflike_args.len()
|
||||
let mut match_arms: Vec<ast::Arm> = variants
|
||||
let mut match_arms: ThinVec<ast::Arm> = variants
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|&(_, v)| !(unify_fieldless_variants && v.data.fields().is_empty()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue