From 2c256cf90401b24604b43733529ede98f348d6ab Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Mon, 3 Jul 2023 12:40:40 +0200 Subject: [PATCH] refactor: quick maths --- src/backup/mod.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/backup/mod.rs b/src/backup/mod.rs index f569697..cb9aa16 100644 --- a/src/backup/mod.rs +++ b/src/backup/mod.rs @@ -235,13 +235,8 @@ impl fmt::Display for Backup { // Pretty-print size // If your backup is a petabyte or larger, this will crash and you need to re-evaluate your // life choices - let mut index = 0; - let mut size = self.size as f64; - - while size >= 1024.0 { - index += 1; - size /= 1024.0; - } + let index = self.size.ilog(1024) as usize; + let size = self.size as f64 / (1024.0_f64.powi(index as i32)); write!( f,