perf: use Vec::with_capacity and reserve_exact (#11904)

This commit is contained in:
nk_ysg
2024-10-21 19:59:09 +08:00
committed by GitHub
parent aba4991d0a
commit f25cceb9f9
13 changed files with 22 additions and 17 deletions

View File

@ -66,7 +66,7 @@ fn generate_many_transactions(senders: usize, max_depth: usize) -> Vec<MockTrans
let rng = TestRng::from_seed(RngAlgorithm::ChaCha, &SEED);
let mut runner = TestRunner::new_with_rng(config, rng);
let mut txs = Vec::new();
let mut txs = Vec::with_capacity(senders);
for idx in 0..senders {
// modulo max_depth so we know it is bounded, plus one so the minimum is always 1
let depth = any::<usize>().new_tree(&mut runner).unwrap().current() % max_depth + 1;