refactor: quick maths
parent
bfd278abbe
commit
2c256cf904
|
@ -235,13 +235,8 @@ impl<T: Clone> fmt::Display for Backup<T> {
|
|||
// 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,
|
||||
|
|
Loading…
Reference in New Issue