From 4d7edd4d15be68146210c3970d2aeddf00570355 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Fri, 31 May 2024 10:15:22 +0100 Subject: [PATCH] fixup --- crates/polars-time/src/truncate.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/polars-time/src/truncate.rs b/crates/polars-time/src/truncate.rs index 5afda307a108..a095ff0628e4 100644 --- a/crates/polars-time/src/truncate.rs +++ b/crates/polars-time/src/truncate.rs @@ -51,6 +51,10 @@ impl PolarsTruncate for DatetimeChunked { } } } + let mut duration_cache = match duration_cache_opt { + Some(cache) => cache, + None => FastFixedCache::new((every.len() as f64).sqrt() as usize), + }; let func = match self.time_unit() { TimeUnit::Nanoseconds => Window::truncate_ns, @@ -71,10 +75,8 @@ impl PolarsTruncate for DatetimeChunked { opt_every, ) { (Some(timestamp), Some(every)) => { - let every = duration_cache_opt - .as_mut() - .map(|cache| *cache.get_or_insert_with(every, |every| Duration::parse(every))) - .unwrap(); + let every = + *duration_cache.get_or_insert_with(every, |every| Duration::parse(every)); if every.negative { polars_bail!(ComputeError: "cannot truncate a Datetime to a negative duration")