[perf] Reserve capacity for argvs.
This avoids unnecessary allocations to grow vector to sufficient size.
This commit is contained in:
parent
31e9f7a6ef
commit
fcceef1838
@ -301,7 +301,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
|
|||||||
// Third argument (`argv`): created from `config.args`.
|
// Third argument (`argv`): created from `config.args`.
|
||||||
let argv = {
|
let argv = {
|
||||||
// Put each argument in memory, collect pointers.
|
// 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() {
|
for arg in config.args.iter() {
|
||||||
// Make space for `0` terminator.
|
// Make space for `0` terminator.
|
||||||
let size = u64::try_from(arg.len()).unwrap().checked_add(1).unwrap();
|
let size = u64::try_from(arg.len()).unwrap().checked_add(1).unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user