[perf] Reserve capacity for argvs.

This avoids unnecessary allocations to grow vector to sufficient size.
This commit is contained in:
Taras Tsugrii 2023-08-07 22:34:54 -05:00 committed by GitHub
parent 31e9f7a6ef
commit fcceef1838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();