From e0afcea9c379f92e26da8b7015b12bc473696d31 Mon Sep 17 00:00:00 2001 From: Hai Nguyen Date: Tue, 19 Nov 2024 11:24:29 +0700 Subject: [PATCH] perf(CacheAccount): remove unneeded clone --- crates/database/src/states/cache_account.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/database/src/states/cache_account.rs b/crates/database/src/states/cache_account.rs index cce76049cb..e3c1bc88a1 100644 --- a/crates/database/src/states/cache_account.rs +++ b/crates/database/src/states/cache_account.rs @@ -282,12 +282,11 @@ impl CacheAccount { storage: StorageWithOriginalValues, ) -> TransitionAccount { let previous_status = self.status; - let previous_info = self.account.as_ref().map(|a| a.info.clone()); - let mut this_storage = self - .account - .take() - .map(|acc| acc.storage) - .unwrap_or_default(); + let (previous_info, mut this_storage) = if let Some(account) = self.account.take() { + (Some(account.info), account.storage) + } else { + (None, Default::default()) + }; this_storage.extend(storage.iter().map(|(k, s)| (*k, s.present_value))); let changed_account = PlainAccount {