From 5f816714119e8884d3b8069184229a05891c6a60 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Fri, 16 Feb 2024 18:37:31 +0100 Subject: [PATCH 1/2] perf(state): avoid cloning full account --- crates/revm/src/db/states/cache_account.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/revm/src/db/states/cache_account.rs b/crates/revm/src/db/states/cache_account.rs index bfe326e5e7..a9fd315450 100644 --- a/crates/revm/src/db/states/cache_account.rs +++ b/crates/revm/src/db/states/cache_account.rs @@ -100,7 +100,7 @@ impl CacheAccount { /// Fetch account info if it exist. pub fn account_info(&self) -> Option { - self.account.clone().map(|a| a.info) + self.account.map(|a| a.info.clone()) } /// Dissolve account into components. @@ -282,7 +282,7 @@ impl CacheAccount { storage: StorageWithOriginalValues, ) -> TransitionAccount { let previous_status = self.status; - let previous_info = self.account.clone().map(|a| a.info); + let previous_info = self.account.map(|a| a.info.clone()); let mut this_storage = self .account .take() @@ -303,7 +303,7 @@ impl CacheAccount { self.account = Some(changed_account); TransitionAccount { - info: self.account.clone().map(|a| a.info), + info: self.account.map(|a| a.info.clone()), status: self.status, previous_info, previous_status, From ab8a68c68c8a63ab25ff1d7cd3f9aeb7a2f52691 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Fri, 16 Feb 2024 18:40:53 +0100 Subject: [PATCH 2/2] fix --- crates/revm/src/db/states/cache_account.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/revm/src/db/states/cache_account.rs b/crates/revm/src/db/states/cache_account.rs index a9fd315450..126ce2ffe7 100644 --- a/crates/revm/src/db/states/cache_account.rs +++ b/crates/revm/src/db/states/cache_account.rs @@ -100,7 +100,7 @@ impl CacheAccount { /// Fetch account info if it exist. pub fn account_info(&self) -> Option { - self.account.map(|a| a.info.clone()) + self.account.as_ref().map(|a| a.info.clone()) } /// Dissolve account into components. @@ -282,7 +282,7 @@ impl CacheAccount { storage: StorageWithOriginalValues, ) -> TransitionAccount { let previous_status = self.status; - let previous_info = self.account.map(|a| a.info.clone()); + let previous_info = self.account.as_ref().map(|a| a.info.clone()); let mut this_storage = self .account .take() @@ -303,7 +303,7 @@ impl CacheAccount { self.account = Some(changed_account); TransitionAccount { - info: self.account.map(|a| a.info.clone()), + info: self.account.as_ref().map(|a| a.info.clone()), status: self.status, previous_info, previous_status,