Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit c45cad9

Browse files
committed
Preallocate space for trail and key_nibbles (minor speedup)
1 parent bfcf114 commit c45cad9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

util/patricia_trie/src/triedb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub struct TrieDBIterator<'a, H: Hasher + 'a, C: NodeCodec<H> + 'a> {
234234
impl<'a, H: Hasher, C: NodeCodec<H>> TrieDBIterator<'a, H, C> {
235235
/// Create a new iterator.
236236
pub fn new(db: &'a TrieDB<H, C>) -> Result<TrieDBIterator<'a, H, C>, H::Out, C::E> {
237-
let mut r = TrieDBIterator { db, trail: vec![], key_nibbles: Vec::new() };
237+
let mut r = TrieDBIterator { db, trail: Vec::with_capacity(8), key_nibbles: Vec::with_capacity(64) };
238238
db.root_data().and_then(|root| r.descend(&root))?;
239239
Ok(r)
240240
}

0 commit comments

Comments
 (0)