refactor: quick maths

export-backup
Jef Roosens 2023-07-03 12:40:40 +02:00
parent bfd278abbe
commit 2c256cf904
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 2 additions and 7 deletions

View File

@ -235,13 +235,8 @@ impl<T: Clone> fmt::Display for Backup<T> {
// Pretty-print size // Pretty-print size
// If your backup is a petabyte or larger, this will crash and you need to re-evaluate your // If your backup is a petabyte or larger, this will crash and you need to re-evaluate your
// life choices // life choices
let mut index = 0; let index = self.size.ilog(1024) as usize;
let mut size = self.size as f64; let size = self.size as f64 / (1024.0_f64.powi(index as i32));
while size >= 1024.0 {
index += 1;
size /= 1024.0;
}
write!( write!(
f, f,