Skip to content

Commit

Permalink
perf(tree): insert account cache only when not present (#14599)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Feb 20, 2025
1 parent 1bf4684 commit c5df8fb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/engine/tree/src/tree/cached_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,12 @@ impl ProviderCaches {
key: StorageKey,
value: Option<StorageValue>,
) {
let account_cache = self.storage_cache.get(&address).unwrap_or_default();

let account_cache = self.storage_cache.get(&address).unwrap_or_else(|| {
let account_cache = AccountStorageCache::default();
self.storage_cache.insert(address, account_cache.clone());
account_cache
});
account_cache.insert_storage(key, value);

self.storage_cache.insert(address, account_cache);
}

/// Invalidate storage for specific account
Expand Down

0 comments on commit c5df8fb

Please sign in to comment.