diff --git a/crates/ruff_python_parser/src/parser/expression.rs b/crates/ruff_python_parser/src/parser/expression.rs index 50581346cc90f5..122b21305adc99 100644 --- a/crates/ruff_python_parser/src/parser/expression.rs +++ b/crates/ruff_python_parser/src/parser/expression.rs @@ -2,6 +2,7 @@ use std::ops::Deref; use bitflags::bitflags; use rustc_hash::{FxBuildHasher, FxHashSet}; +use thin_vec::ThinVec; use ruff_python_ast::name::Name; use ruff_python_ast::token::TokenKind; @@ -806,7 +807,7 @@ impl<'src> Parser<'src> { self.bump(TokenKind::Lpar); let mut args = vec![]; - let mut keywords = vec![]; + let mut keywords = ThinVec::new(); let mut seen_keyword_argument = false; // foo = 1 let mut seen_keyword_unpacking = false; // **foo @@ -933,11 +934,13 @@ impl<'src> Parser<'src> { self.expect(TokenKind::Rpar); + keywords.shrink_to_fit(); + let arguments = ast::Arguments { range: self.node_range(start), node_index: AtomicNodeIndex::NONE, args: args.into_boxed_slice(), - keywords: keywords.into(), + keywords, }; self.validate_arguments(&arguments, has_trailing_comma, context);