Skip to content

Commit

Permalink
perf: relax condition in seek_inner (#13614)
Browse files Browse the repository at this point in the history
  • Loading branch information
kien-rise authored Jan 7, 2025
1 parent 107dfae commit c74b8f0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/trie/trie/src/trie_cursor/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'a, C: TrieCursor> InMemoryAccountTrieCursor<'a, C> {
exact: bool,
) -> Result<Option<(Nibbles, BranchNodeCompact)>, DatabaseError> {
let in_memory = self.in_memory_cursor.seek(&key);
if exact && in_memory.as_ref().is_some_and(|entry| entry.0 == key) {
if in_memory.as_ref().is_some_and(|entry| entry.0 == key) {
return Ok(in_memory)
}

Expand Down Expand Up @@ -202,9 +202,7 @@ impl<C: TrieCursor> InMemoryStorageTrieCursor<'_, C> {
exact: bool,
) -> Result<Option<(Nibbles, BranchNodeCompact)>, DatabaseError> {
let in_memory = self.in_memory_cursor.as_mut().and_then(|c| c.seek(&key));
if self.storage_trie_cleared ||
(exact && in_memory.as_ref().is_some_and(|entry| entry.0 == key))
{
if self.storage_trie_cleared || in_memory.as_ref().is_some_and(|entry| entry.0 == key) {
return Ok(in_memory.filter(|(nibbles, _)| !exact || nibbles == &key))
}

Expand Down

0 comments on commit c74b8f0

Please sign in to comment.