Auto merge of #3019 - ttsugriy:ttsugriy-patch-1-1, r=RalfJung

[perf] Reserve capacity for argvs.

This avoids unnecessary allocations to grow vector to sufficient size.
This commit is contained in:
bors 2023-08-08 06:13:17 +00:00
commit 4b2ec291ea

View File

@ -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::<Immediate<Provenance>>::new();
let mut argvs = Vec::<Immediate<Provenance>>::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();