Allocate one less vec in parser/expr.rs

This commit is contained in:
Maybe Waffle 2023-01-14 11:44:25 +00:00
parent 5ca6f7d2c3
commit ea13023b36

View File

@ -1471,9 +1471,8 @@ impl<'a> Parser<'a> {
} else if self.eat(&token::Comma) {
// Vector with two or more elements.
let sep = SeqSep::trailing_allowed(token::Comma);
let (remaining_exprs, _) = self.parse_seq_to_end(close, sep, |p| p.parse_expr())?;
let mut exprs = vec![first_expr];
exprs.extend(remaining_exprs);
let (mut exprs, _) = self.parse_seq_to_end(close, sep, |p| p.parse_expr())?;
exprs.insert(0, first_expr);
ExprKind::Array(exprs)
} else {
// Vector with one element