Use vec![0; size] instead of creating an empty Vec and resizing.

This commit is contained in:
Dan Gohman
2019-01-03 14:08:31 -08:00
parent a41bc1fe1e
commit 585bdac91e
2 changed files with 5 additions and 14 deletions

View File

@@ -158,9 +158,8 @@ pub fn invoke(
// TODO: Support values larger than u64. And pack the values into memory
// instead of just using fixed-sized slots.
let mut values_vec: Vec<u64> = Vec::new();
let value_size = mem::size_of::<u64>();
values_vec.resize(max(signature.params.len(), signature.returns.len()), 0u64);
let mut values_vec: Vec<u64> = vec![0; max(signature.params.len(), signature.returns.len())];
// Store the argument values into `values_vec`.
for (index, arg) in args.iter().enumerate() {