Improve overall performance (#6699)

* Improve overall performance

* Clean up code

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Remove needless ::

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Remove needless ::

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
pscott
2020-07-21 14:46:49 +02:00
committed by GitHub
parent ab82eb1c98
commit 046fda914a
73 changed files with 141 additions and 144 deletions
@@ -20,6 +20,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use sp_std::{
vec,
borrow::Cow, marker::PhantomData, mem, iter::Iterator, result, vec::Vec,
};
@@ -275,8 +276,7 @@ impl PartialEq for dyn Function {
pub trait FunctionContext {
/// Read memory from `address` into a vector.
fn read_memory(&self, address: Pointer<u8>, size: WordSize) -> Result<Vec<u8>> {
let mut vec = Vec::with_capacity(size as usize);
vec.resize(size as usize, 0);
let mut vec = vec![0; size as usize];
self.read_memory_into(address, &mut vec)?;
Ok(vec)
}