Skip to content

Commit 2bb9163

Browse files
committed
minor improvement
1 parent 58b17b6 commit 2bb9163

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

  • crates/eth-sparse-mpt/src

crates/eth-sparse-mpt/src/v1/reth_sparse_trie/trie_fetcher/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ where
105105
}
106106
}
107107

108-
fn pad_path(mut path: Nibbles) -> B256 {
109-
while path.len() < 64 {
110-
path.push_unchecked(0);
111-
}
108+
fn pad_path(path: Nibbles) -> B256 {
109+
// `pack_to` writes left-aligned into the zeroed buffer
112110
let mut res = B256::default();
113111
path.pack_to(res.as_mut_slice());
114112
res

crates/eth-sparse-mpt/src/v_experimental/fetch.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ impl MissingNodesFetcher {
138138
}
139139
}
140140

141-
fn pad_path(mut path: Nibbles) -> B256 {
142-
while path.len() < 64 {
143-
path.push_unchecked(0);
144-
}
141+
fn pad_path(path: Nibbles) -> B256 {
142+
// `pack_to` writes left-aligned into the zeroed buffer, leaving trailing
143+
// bytes zero, so explicit right-padding to 64 nibbles is unnecessary.
145144
let mut res = B256::default();
146145
path.pack_to(res.as_mut_slice());
147146
res

0 commit comments

Comments
 (0)