Use Vec::with_capacity() to avoid reallocations with repeated push()'s (#34242)
The length of tx_cells is known before the loop that populates it, so we can appropriately allocate the Vec immediatley to avoid any reallocations.
This commit is contained in:
parent
32c7acbf74
commit
4d2018fc6e
|
@ -885,7 +885,7 @@ impl LedgerStorage {
|
|||
);
|
||||
let mut by_addr: HashMap<&Pubkey, Vec<TransactionByAddrInfo>> = HashMap::new();
|
||||
|
||||
let mut tx_cells = vec![];
|
||||
let mut tx_cells = Vec::with_capacity(confirmed_block.transactions.len());
|
||||
for (index, transaction_with_meta) in confirmed_block.transactions.iter().enumerate() {
|
||||
let VersionedTransactionWithStatusMeta { meta, transaction } = transaction_with_meta;
|
||||
let err = meta.status.clone().err();
|
||||
|
|
Loading…
Reference in New Issue