From fcceef1838b09cffdc94eca97788b45a29e1299f Mon Sep 17 00:00:00 2001 From: Taras Tsugrii Date: Mon, 7 Aug 2023 22:34:54 -0500 Subject: [PATCH] [perf] Reserve capacity for argvs. This avoids unnecessary allocations to grow vector to sufficient size. --- src/tools/miri/src/eval.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs index b761a6cf475..88e7d5386db 100644 --- a/src/tools/miri/src/eval.rs +++ b/src/tools/miri/src/eval.rs @@ -301,7 +301,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( // Third argument (`argv`): created from `config.args`. let argv = { // Put each argument in memory, collect pointers. - let mut argvs = Vec::>::new(); + let mut argvs = Vec::>::with_capacity(config.args.len()); for arg in config.args.iter() { // Make space for `0` terminator. let size = u64::try_from(arg.len()).unwrap().checked_add(1).unwrap();