Skip to content

Commit 24d88d7

Browse files
committed
shred:bitwise method to set OPTIMAL_IO_BLOCK_SIZE
The value of the variable remains unchanged (4096 = 2 ^ 12), but using a bitwise expression provides two benefits: - follows the same approach used for configuring BLOCK_SIZE - indicates that a power-of-two value is preferred for this kind of constant
1 parent 9fce1a1 commit 24d88d7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/uu/shred/src/shred.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ const NAME_CHARSET: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN
4949
const PATTERN_LENGTH: usize = 3;
5050
const PATTERN_BUFFER_SIZE: usize = BLOCK_SIZE + PATTERN_LENGTH - 1;
5151

52-
/// Optimal block size for the filesystem. This constant is used for data size alignment,
53-
/// similar to the behavior of GNU shred. Usually, optimal block size is a 4K block, which is why
52+
/// Optimal block size for the filesystem. This constant is used for data size alignment, similar
53+
/// to the behavior of GNU shred. Usually, optimal block size is a 4K block (2^12), which is why
5454
/// it's defined as a constant. However, it's possible to get the actual size at runtime using, for
5555
/// example, `std::os::unix::fs::MetadataExt::blksize()`.
56-
const OPTIMAL_IO_BLOCK_SIZE: usize = 4096;
56+
const OPTIMAL_IO_BLOCK_SIZE: usize = 1 << 12;
5757

5858
/// Patterns that appear in order for the passes
5959
///

0 commit comments

Comments
 (0)