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
@@ -171,7 +171,7 @@ impl<S: TrieBackendStorage<H>, H: Hasher> TrieBackendEssence<S, H> where H::Out:
key: &[u8],
) -> Result<Option<StorageValue>, String> {
let root = self.child_root(child_info)?
.unwrap_or(empty_child_trie_root::<Layout<H>>().encode());
.unwrap_or_else(|| empty_child_trie_root::<Layout<H>>().encode());
let map_e = |e| format!("Trie lookup error: {}", e);
@@ -186,7 +186,7 @@ impl<S: TrieBackendStorage<H>, H: Hasher> TrieBackendEssence<S, H> where H::Out:
f: F,
) {
let root = match self.child_root(child_info) {
Ok(v) => v.unwrap_or(empty_child_trie_root::<Layout<H>>().encode()),
Ok(v) => v.unwrap_or_else(|| empty_child_trie_root::<Layout<H>>().encode()),
Err(e) => {
debug!(target: "trie", "Error while iterating child storage: {}", e);
return;
@@ -211,7 +211,7 @@ impl<S: TrieBackendStorage<H>, H: Hasher> TrieBackendEssence<S, H> where H::Out:
mut f: F,
) {
let root_vec = match self.child_root(child_info) {
Ok(v) => v.unwrap_or(empty_child_trie_root::<Layout<H>>().encode()),
Ok(v) => v.unwrap_or_else(|| empty_child_trie_root::<Layout<H>>().encode()),
Err(e) => {
debug!(target: "trie", "Error while iterating child storage: {}", e);
return;