perf(tree): insert account cache only when not present (#14599)

This commit is contained in:
DaniPopes
2025-02-20 07:52:29 +01:00
committed by GitHub
parent 1bf46848a6
commit c5df8fbaaf

View File

@ -356,11 +356,12 @@ impl ProviderCaches {
key: StorageKey, key: StorageKey,
value: Option<StorageValue>, 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); account_cache.insert_storage(key, value);
self.storage_cache.insert(address, account_cache);
} }
/// Invalidate storage for specific account /// Invalidate storage for specific account