Set the capacity of the Vec used in gather_captures() to the number of captures expected (#13339)

# Description

Just more efficient allocation during `Stack::gather_captures()` so that
we don't have to grow the `Vec` needlessly.

# User-Facing Changes
Slightly better performance.
This commit is contained in:
Devyn Cairns 2024-07-10 19:13:35 -07:00 committed by GitHub
parent ac561b1b0e
commit f87cf895c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -277,7 +277,7 @@ impl Stack {
}
pub fn gather_captures(&self, engine_state: &EngineState, captures: &[VarId]) -> Stack {
let mut vars = vec![];
let mut vars = Vec::with_capacity(captures.len());
let fake_span = Span::new(0, 0);