From 28e9a880773510fd2f8790a0cbb2fba4bc1581ee Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 20 Nov 2024 09:10:39 +0100 Subject: [PATCH] du: use div_ceil() from std --- src/uu/du/src/du.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index a35e9f77e..3681668f0 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -555,7 +555,7 @@ impl StatPrinter { size, uucore::format::human::SizeFormat::Binary, ), - SizeFormat::BlockSize(block_size) => div_ceil(size, block_size).to_string(), + SizeFormat::BlockSize(block_size) => size.div_ceil(block_size).to_string(), } } @@ -576,13 +576,6 @@ impl StatPrinter { } } -// This can be replaced with u64::div_ceil once it is stabilized. -// This implementation approach is optimized for when `b` is a constant, -// particularly a power of two. -pub fn div_ceil(a: u64, b: u64) -> u64 { - (a + b - 1) / b -} - // Read file paths from the specified file, separated by null characters fn read_files_from(file_name: &str) -> Result, std::io::Error> { let reader: Box = if file_name == "-" {