mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
perf(trie): use is_zero() check to avoid copy in is_storage_empty (#21459)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -79,7 +79,7 @@ impl HashedPostStateCursorValue for U256 {
|
||||
type NonZero = Self;
|
||||
|
||||
fn into_option(self) -> Option<Self::NonZero> {
|
||||
(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<bool, DatabaseError> {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user