ct/cmp: save the final shift by switching the direction of shifts
This commit is contained in:
parent
d90236bfb9
commit
fb2139eeee
10
ct.c
10
ct.c
@ -25,10 +25,10 @@ lc_ct_cmp(const uint8_t *x, const uint8_t *y, size_t l)
|
|||||||
for (; l > 0; l--)
|
for (; l > 0; l--)
|
||||||
r |= *x++ ^ *y++;
|
r |= *x++ ^ *y++;
|
||||||
|
|
||||||
/* Ensures that if any bit is set, then bit 7 is set. */
|
/* Ensures that if any bit is set, then LSB is set. */
|
||||||
r |= r << 4;
|
r |= r >> 4;
|
||||||
r |= r << 2;
|
r |= r >> 2;
|
||||||
r |= r << 1;
|
r |= r >> 1;
|
||||||
|
|
||||||
return 0xffffffff + ((r & 0x80) >> 7);
|
return 0xffffffff + (r & 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user