1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Rename bytes to hex, allocate String with capacity.

This commit is contained in:
David Campbell 2024-09-28 16:09:41 -04:00
parent ae01996066
commit d338206a62
No known key found for this signature in database
GPG key ID: C2E99A0CF863A603

View file

@ -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(