Rollup merge of #106849 - WaffleLapkin:unvec, r=Nilstrieb

Allocate one less vec while parsing arrays

Probably does not matter, but imo a little bit nicer.
This commit is contained in:
Matthias Krüger 2023-01-14 18:45:28 +01:00 committed by GitHub
commit 9db8e6d5e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -1475,9 +1475,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