diff --git a/src/uucore/src/lib/features/checksum.rs b/src/uucore/src/lib/features/checksum.rs index 1eb20397d..c55d56393 100644 --- a/src/uucore/src/lib/features/checksum.rs +++ b/src/uucore/src/lib/features/checksum.rs @@ -322,10 +322,12 @@ fn determine_regex(lines: &[String]) -> Option<(Regex, bool)> { // Converts bytes to a hexadecimal string fn bytes_to_hex(bytes: &[u8]) -> String { - bytes.iter().fold(String::new(), |mut bytes, byte| { - write!(bytes, "{byte:02x}").unwrap(); - bytes - }) + bytes + .iter() + .fold(String::with_capacity(bytes.len() * 2), |mut hex, byte| { + write!(hex, "{byte:02x}").unwrap(); + hex + }) } fn get_expected_checksum(