Skip to content

Commit

Permalink
Buffers of 16 or multiple of 16 bytes are not fully processed by hot …
Browse files Browse the repository at this point in the history
…loop (off by one in check)
  • Loading branch information
khrs committed Feb 23, 2023
1 parent 007687a commit 76a053b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/crc128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const fn update_slice16(
let mut i = 0;
let len = bytes.len();
if reflect {
while i + 16 < len {
while i + 16 <= len {
assert!((i + 15) < len);

let current0 = bytes[i] ^ crc as u8;
Expand Down Expand Up @@ -123,7 +123,7 @@ const fn update_slice16(
i += 1;
}
} else {
while i + 16 < len {
while i + 16 <= len {
assert!((i + 15) < len);

let current0 = bytes[i] ^ (crc >> 120) as u8;
Expand Down
5 changes: 3 additions & 2 deletions src/crc16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ const fn update_slice16(
) -> u16 {
let len = bytes.len();
let mut i = 0;

if reflect {
while i + 16 < len {
while i + 16 <= len {
assert!((i + 15) < len);

let current0 = bytes[i] ^ (crc as u8);
Expand Down Expand Up @@ -108,7 +109,7 @@ const fn update_slice16(
i += 1;
}
} else {
while i + 16 < len {
while i + 16 <= len {
assert!((i + 15) < len);

let current0 = bytes[i] ^ ((crc >> 8) as u8);
Expand Down
4 changes: 2 additions & 2 deletions src/crc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const fn update_slice16(
let mut i = 0;
let len = bytes.len();
if reflect {
while i + 16 < len {
while i + 16 <= len {
assert!((i + 15) < len);

let current0 = bytes[i] ^ crc as u8;
Expand Down Expand Up @@ -116,7 +116,7 @@ const fn update_slice16(
i += 1;
}
} else {
while i + 16 < len {
while i + 16 <= len {
assert!((i + 15) < len);

let current0 = bytes[i] ^ (crc >> 56) as u8;
Expand Down
2 changes: 1 addition & 1 deletion src/crc8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const fn update_slice16(mut crc: u8, table: &[[u8; 256]; 16], bytes: &[u8]) -> u
let len = bytes.len();
let mut i = 0;

while i + 16 < len {
while i + 16 <= len {
assert!((i + 15) < len);

crc = table[0][bytes[i + 15] as usize]
Expand Down

0 comments on commit 76a053b

Please sign in to comment.