Skip to content

Commit

Permalink
avoid unneccessary to_vec -> into_iter
Browse files Browse the repository at this point in the history
  • Loading branch information
apfitzge committed May 18, 2023
1 parent ca20a5e commit 9871481
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,27 +430,23 @@ impl Consumer {
// Need to filter out transactions since they were sanitized earlier.
// This means that the transaction may cross and epoch boundary (not allowed),
// or account lookup tables may have been closed.
let pre_results = txs
.iter()
.zip(max_slot_ages)
.map(|(tx, max_slot_age)| {
if *max_slot_age < bank.slot() {
// Attempt re-sanitization after epoch-cross.
// Re-sanitized transaction should be equal to the original transaction,
// but whether it will pass sanitization needs to be checked.
resanitize(tx, bank)?;
} else {
// Any transaction executed between sanitization time and now may have closed the lookup table(s).
// Above re-sanitization already loads addresses, so don't need to re-check in that case.
let lookup_tables = tx.message().message_address_table_lookups();
if !lookup_tables.is_empty() {
bank.load_addresses(lookup_tables)?;
}
let pre_results = txs.iter().zip(max_slot_ages).map(|(tx, max_slot_age)| {
if *max_slot_age < bank.slot() {
// Attempt re-sanitization after epoch-cross.
// Re-sanitized transaction should be equal to the original transaction,
// but whether it will pass sanitization needs to be checked.
resanitize(tx, bank)?;
} else {
// Any transaction executed between sanitization time and now may have closed the lookup table(s).
// Above re-sanitization already loads addresses, so don't need to re-check in that case.
let lookup_tables = tx.message().message_address_table_lookups();
if !lookup_tables.is_empty() {
bank.load_addresses(lookup_tables)?;
}
Ok(())
})
.collect_vec();
self.process_and_record_transactions_with_pre_results(bank, txs, 0, pre_results.into_iter())
}
Ok(())
});
self.process_and_record_transactions_with_pre_results(bank, txs, 0, pre_results)
}

fn process_and_record_transactions_with_pre_results(
Expand Down

0 comments on commit 9871481

Please sign in to comment.