From 4579c1bfba4eca21d7480694780e39f6966a88a0 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 19 Oct 2024 18:36:15 -0400 Subject: [PATCH] `stats`: cache njobs result --- src/cmd/stats.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/stats.rs b/src/cmd/stats.rs index 2b0405b2c..0b17d1dce 100644 --- a/src/cmd/stats.rs +++ b/src/cmd/stats.rs @@ -497,6 +497,7 @@ const MAX_ANTIMODES: usize = 10; // maximum length of antimode string before truncating and appending "..." const MAX_ANTIMODE_LEN: usize = 100; +// we do this so this is evaluated at compile-time pub const fn get_stats_data_types() -> [JsonTypes; MAX_STAT_COLUMNS] { STATSDATA_TYPES_ARRAY } @@ -939,10 +940,11 @@ impl Args { init_date_inference(self.flag_infer_dates, &headers, whitelist)?; - let chunk_size = util::chunk_size(idx_count as usize, util::njobs(self.flag_jobs)); + let njobs = util::njobs(self.flag_jobs); + let chunk_size = util::chunk_size(idx_count as usize, njobs); let nchunks = util::num_of_chunks(idx_count as usize, chunk_size); - let pool = ThreadPool::new(util::njobs(self.flag_jobs)); + let pool = ThreadPool::new(njobs); let (send, recv) = crossbeam_channel::bounded(0); for i in 0..nchunks { let (send, args, sel) = (send.clone(), self.clone(), sel.clone());