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

Merge pull request #5115 from resistor/rotate

Use `rotate_right` rather than an explicit expansion in `sum`
This commit is contained in:
Daniel Hofstetter 2023-07-29 16:42:45 +02:00 committed by GitHub
commit a9dde668ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,7 +34,7 @@ fn bsd_sum(mut reader: Box<dyn Read>) -> (usize, u16) {
Ok(n) if n != 0 => {
bytes_read += n;
for &byte in buf[..n].iter() {
checksum = (checksum >> 1) + ((checksum & 1) << 15);
checksum = checksum.rotate_right(1);
checksum = checksum.wrapping_add(u16::from(byte));
}
}