refactor: use branchless handling for odd byte in checksum
This commit is contained in:
parent
69a6a633d4
commit
1434409738
1 changed files with 1 additions and 2 deletions
|
|
@ -42,8 +42,7 @@ sum_words(const uint8_t *data, size_t len)
|
|||
}
|
||||
|
||||
/* Handle odd byte if present */
|
||||
if (len & 1)
|
||||
sum += (uint32_t)(*ptr << 8);
|
||||
sum += ((uint32_t)(*ptr << 8)) & -(len & 1);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue