Reduce 2 iterators to one (#25973)

This commit is contained in:
Tyera Eulberg 2022-06-14 16:49:58 -06:00 committed by GitHub
parent 4652377e5b
commit 8a3d48b0ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -324,14 +324,16 @@ fn execute_batches(
cost_capacity_meter: Arc<RwLock<BlockCostCapacityMeter>>,
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::<Vec<_>>();
let sanitized_txs = batches
.iter()
.flat_map(|batch| batch.sanitized_transactions().to_vec())
.collect::<Vec<_>>();
.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;