Skip to content

Commit

Permalink
Auto merge of rust-lang#3019 - ttsugriy:ttsugriy-patch-1-1, r=RalfJung
Browse files Browse the repository at this point in the history
[perf] Reserve capacity for argvs.

This avoids unnecessary allocations to grow vector to sufficient size.
  • Loading branch information
bors committed Aug 8, 2023
2 parents 31e9f7a + fcceef1 commit 4b2ec29
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tools/miri/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4b2ec29

Please sign in to comment.