From 9c6df6b3baae02c255ae5042edde45eecefdc3fc Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 14 Jun 2022 13:48:16 -0600 Subject: [PATCH] Reduce 2 iterators to one --- ledger/src/blockstore_processor.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 12a04e519b7356..dd92c4288df5c4 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -324,14 +324,16 @@ fn execute_batches( cost_capacity_meter: Arc>, cost_model: &CostModel, ) -> Result<()> { - let lock_results = batches + let (lock_results, sanitized_txs): (Vec<_>, Vec<_>) = batches .iter() - .flat_map(|batch| batch.lock_results().clone()) - .collect::>(); - let sanitized_txs = batches - .iter() - .flat_map(|batch| batch.sanitized_transactions().to_vec()) - .collect::>(); + .flat_map(|batch| { + batch + .lock_results() + .iter() + .cloned() + .zip(batch.sanitized_transactions().to_vec()) + }) + .unzip(); let mut minimal_tx_cost = u64::MAX; let mut total_cost: u64 = 0;