From f724e18f9ac8021af8695405271f7bea7e90a0d1 Mon Sep 17 00:00:00 2001 From: tuxuser <462620+tuxuser@users.noreply.github.com> Date: Fri, 1 Dec 2023 02:31:28 +0100 Subject: [PATCH] Avoid unnecessary checked division --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f0bf20f..2588776 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,7 +81,7 @@ impl FileTime { /// let ft_i64 = FileTime::now().filetime(); /// ``` pub fn filetime(&self) -> i64 { - (self.secs * Self::HUNDREDS_OF_NANOSECONDS) + self.nsecs.checked_div(100).unwrap_or(0) + (self.secs * Self::HUNDREDS_OF_NANOSECONDS) + self.nsecs / 100 } /// Return FILETIME epoch as DateTime @@ -115,7 +115,7 @@ impl FileTime { pub fn from_datetime(dt: DateTime) -> Self { let nsecs = Self::EPOCH_AS_FILETIME + (dt.timestamp() * Self::HUNDREDS_OF_NANOSECONDS) - + dt.timestamp_subsec_nanos().checked_div(100).unwrap_or(0) as i64; + + (dt.timestamp_subsec_nanos() / 100) as i64; Self::from_i64(nsecs) }