Skip to content

Commit 4f76291

Browse files
authored
[v50] perf: remove unneeded clones (#1863)
* perf(CacheAccount): remove unneeded clone * perf(TransitionAccount): remove unneeded clone
1 parent 9519b11 commit 4f76291

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

crates/revm/src/db/states/cache_account.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,11 @@ impl CacheAccount {
282282
storage: StorageWithOriginalValues,
283283
) -> TransitionAccount {
284284
let previous_status = self.status;
285-
let previous_info = self.account.as_ref().map(|a| a.info.clone());
286-
let mut this_storage = self
287-
.account
288-
.take()
289-
.map(|acc| acc.storage)
290-
.unwrap_or_default();
285+
let (previous_info, mut this_storage) = if let Some(account) = self.account.take() {
286+
(Some(account.info), account.storage)
287+
} else {
288+
(None, Default::default())
289+
};
291290

292291
this_storage.extend(storage.iter().map(|(k, s)| (*k, s.present_value)));
293292
let changed_account = PlainAccount {

crates/revm/src/db/states/transition_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl TransitionAccount {
8585
/// Update new values of transition. Don't override old values.
8686
/// Both account info and old storages need to be left intact.
8787
pub fn update(&mut self, other: Self) {
88-
self.info.clone_from(&other.info);
88+
self.info = other.info;
8989
self.status = other.status;
9090

9191
// if transition is from some to destroyed drop the storage.

0 commit comments

Comments
 (0)