From 226ce14ca1ca976bd6595c26a5fe89fd6b9909a9 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 27 Jan 2026 01:42:26 +0100 Subject: [PATCH] perf(trie): use is_zero() check to avoid copy in is_storage_empty (#21459) Co-authored-by: Amp --- crates/trie/trie/src/hashed_cursor/post_state.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/trie/trie/src/hashed_cursor/post_state.rs b/crates/trie/trie/src/hashed_cursor/post_state.rs index 7436e46694..9e5bf66990 100644 --- a/crates/trie/trie/src/hashed_cursor/post_state.rs +++ b/crates/trie/trie/src/hashed_cursor/post_state.rs @@ -79,7 +79,7 @@ impl HashedPostStateCursorValue for U256 { type NonZero = Self; fn into_option(self) -> Option { - (self != Self::ZERO).then_some(self) + (!self.is_zero()).then_some(self) } } @@ -351,7 +351,7 @@ where /// [`HashedCursor::next`]. fn is_storage_empty(&mut self) -> Result { // Storage is not empty if it has non-zero slots. - if self.post_state_cursor.has_any(|(_, value)| value.into_option().is_some()) { + if self.post_state_cursor.has_any(|(_, value)| !value.is_zero()) { return Ok(false); }