From 4d2c5767ec44004af023500dafb7ee9a1193cd72 Mon Sep 17 00:00:00 2001 From: Hai | RISE <150876604+hai-rise@users.noreply.github.com> Date: Sat, 7 Dec 2024 12:30:36 +0700 Subject: [PATCH] perf(txpool): remove more clones (#13189) --- crates/transaction-pool/src/pool/txpool.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/transaction-pool/src/pool/txpool.rs b/crates/transaction-pool/src/pool/txpool.rs index 5820b5f894..dd6da1d0fe 100644 --- a/crates/transaction-pool/src/pool/txpool.rs +++ b/crates/transaction-pool/src/pool/txpool.rs @@ -462,10 +462,12 @@ impl TxPool { &mut self, changed_senders: FxHashMap, ) -> UpdateOutcome { - // track changed accounts - self.sender_info.extend(changed_senders.clone()); // Apply the state changes to the total set of transactions which triggers sub-pool updates. - let updates = self.all_transactions.update(changed_senders); + let updates = self.all_transactions.update(&changed_senders); + + // track changed accounts + self.sender_info.extend(changed_senders); + // Process the sub-pool updates let update = self.process_updates(updates); // update the metrics after the update @@ -1183,7 +1185,7 @@ impl AllTransactions { /// that got transaction included in the block. pub(crate) fn update( &mut self, - changed_accounts: FxHashMap, + changed_accounts: &FxHashMap, ) -> Vec { // pre-allocate a few updates let mut updates = Vec::with_capacity(64); @@ -1240,7 +1242,7 @@ impl AllTransactions { } } - changed_balance = Some(info.balance); + changed_balance = Some(&info.balance); } // If there's a nonce gap, we can shortcircuit, because there's nothing to update yet. @@ -1291,7 +1293,7 @@ impl AllTransactions { // If the account changed in the block, check the balance. if let Some(changed_balance) = changed_balance { - if cumulative_cost > changed_balance { + if &cumulative_cost > changed_balance { // sender lacks sufficient funds to pay for this transaction tx.state.remove(TxState::ENOUGH_BALANCE); } else {