diff --git a/fuel-merkle/src/binary/merkle_tree.rs b/fuel-merkle/src/binary/merkle_tree.rs index 276a36367d..fcfd39b455 100644 --- a/fuel-merkle/src/binary/merkle_tree.rs +++ b/fuel-merkle/src/binary/merkle_tree.rs @@ -221,8 +221,8 @@ where storage: StorageType, leaves_count: u64, ) -> Result> { - let mut nodes = Vec::new(); let peaks = peak_positions(leaves_count).ok_or(MerkleTreeError::TooLarge)?; + let mut nodes = Vec::with_capacity(peaks.len()); for peak in peaks.iter() { let key = peak.in_order_index(); let node = storage diff --git a/fuel-tx/src/transaction/metadata.rs b/fuel-tx/src/transaction/metadata.rs index b66dde9b6b..5aada94850 100644 --- a/fuel-tx/src/transaction/metadata.rs +++ b/fuel-tx/src/transaction/metadata.rs @@ -81,7 +81,7 @@ impl CommonMetadata { .collect_vec(); let mut offset = tx.inputs_offset(); - let mut inputs_offset_at = Vec::new(); + let mut inputs_offset_at = Vec::with_capacity(tx.inputs().len()); for (index, input) in tx.inputs().iter().enumerate() { let i = offset; offset = offset @@ -91,7 +91,7 @@ impl CommonMetadata { } let mut offset = tx.outputs_offset(); - let mut outputs_offset_at = Vec::new(); + let mut outputs_offset_at = Vec::with_capacity(tx.outputs().len()); for (index, output) in tx.outputs().iter().enumerate() { let i = offset; offset = offset @@ -101,7 +101,7 @@ impl CommonMetadata { } let mut offset = tx.witnesses_offset(); - let mut witnesses_offset_at = Vec::new(); + let mut witnesses_offset_at = Vec::with_capacity(tx.witnesses().len()); for (index, witnesses) in tx.witnesses().iter().enumerate() { let i = offset; offset = offset