From cd7d890ed2f21b1cc0fe5502f4d8396b26dd1250 Mon Sep 17 00:00:00 2001 From: hana <81144685+2501babe@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:34:20 +0000 Subject: [PATCH] dont need to collect lock results --- accounts-db/src/accounts.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/accounts-db/src/accounts.rs b/accounts-db/src/accounts.rs index a8fecadead478f..c3a76abaf98d69 100644 --- a/accounts-db/src/accounts.rs +++ b/accounts-db/src/accounts.rs @@ -565,12 +565,11 @@ impl Accounts { relax_intrabatch_account_locks: bool, ) -> Vec> { // Validate the account locks, then get iterator if successful validation. - let tx_account_locks_results: Vec> = txs + let tx_account_locks_results = txs .map(|tx| { validate_account_locks(tx.account_keys(), tx_account_lock_limit) .map(|_| TransactionAccountLocksIterator::new(tx)) - }) - .collect(); + }); self.lock_accounts_inner(tx_account_locks_results, relax_intrabatch_account_locks) } @@ -583,27 +582,25 @@ impl Accounts { relax_intrabatch_account_locks: bool, ) -> Vec> { // Validate the account locks, then get iterator if successful validation. - let tx_account_locks_results: Vec> = txs + let tx_account_locks_results = txs .zip(results) .map(|(tx, result)| match result { Ok(()) => validate_account_locks(tx.account_keys(), tx_account_lock_limit) .map(|_| TransactionAccountLocksIterator::new(tx)), Err(err) => Err(err), - }) - .collect(); + }); self.lock_accounts_inner(tx_account_locks_results, relax_intrabatch_account_locks) } #[must_use] - fn lock_accounts_inner( + fn lock_accounts_inner<'a>( &self, - tx_account_locks_results: Vec>>, + tx_account_locks_results: impl Iterator>>, relax_intrabatch_account_locks: bool, ) -> Vec> { let account_locks = &mut self.account_locks.lock().unwrap(); if relax_intrabatch_account_locks { let validated_batch_keys = tx_account_locks_results - .into_iter() .map(|tx_account_locks_result| { tx_account_locks_result .map(|tx_account_locks| tx_account_locks.accounts_with_is_writable()) @@ -613,7 +610,6 @@ impl Accounts { account_locks.try_lock_transaction_batch(validated_batch_keys) } else { tx_account_locks_results - .into_iter() .map(|tx_account_locks_result| match tx_account_locks_result { Ok(tx_account_locks) => account_locks .try_lock_accounts(tx_account_locks.accounts_with_is_writable()),