From 6ca0100106cfa9ff5d4b7d9e04112ee50ca912e0 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Mon, 18 Nov 2024 00:31:07 -0500 Subject: [PATCH] chore: prealloc stats_br_vec; remove old commented code --- src/cmd/stats.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cmd/stats.rs b/src/cmd/stats.rs index f1b3e59fe..7eecfdf73 100644 --- a/src/cmd/stats.rs +++ b/src/cmd/stats.rs @@ -772,7 +772,9 @@ pub fn run(argv: &[&str]) -> CliResult<()> { let stats_sr_vec = args.stats_to_records(stats); let mut work_br; - let mut stats_br_vec: Vec = Vec::new(); + + // prealloc. we add 4 for the 4 addl dataset-level stats + let mut stats_br_vec: Vec = Vec::with_capacity(stats_sr_vec.len() + 4); let stats_headers_sr = args.stat_headers(); wtr.write_record(&stats_headers_sr)?; @@ -784,7 +786,6 @@ pub fn run(argv: &[&str]) -> CliResult<()> { header.to_vec() }; let stat = stat.iter().map(str::as_bytes); - // work_var = vec![&*header].into_iter().chain(stat); work_br = csv::ByteRecord::from_iter(vec![&*header].into_iter().chain(stat)); wtr.write_record(&work_br)?; stats_br_vec.push(work_br);