Skip to content

Commit

Permalink
perf: move common_prefix_len out of loop (#5036)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsdan authored and mattsse committed Nov 8, 2023
1 parent c50e9e2 commit 79dc903
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/primitives/src/trie/hash_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ impl HashBuilder {

tracing::debug!(target: "trie::hash_builder", ?current, ?succeeding, "updating merkle tree");

let common_prefix_len = succeeding.common_prefix_length(&current);
let mut i = 0;
loop {
let span = tracing::span!(
Expand All @@ -197,7 +198,6 @@ impl HashBuilder {
let preceding_exists = !self.groups.is_empty();
let preceding_len: usize = self.groups.len().saturating_sub(1);

let common_prefix_len = succeeding.common_prefix_length(&current);
let len = std::cmp::max(preceding_len, common_prefix_len);
assert!(len < current.len());

Expand Down

0 comments on commit 79dc903

Please sign in to comment.