Avoid conditions inside loop

This commit is contained in:
Anatol Belski 2018-02-09 17:47:03 +01:00
parent 3e6492f305
commit d3cb224eb3

View File

@ -160,15 +160,16 @@ fnv_32_buf(void *buf, size_t len, uint32_t hval, int alternate)
/* /*
* FNV-1 hash each octet in the buffer * FNV-1 hash each octet in the buffer
*/ */
while (bp < be) { if (alternate == 0) {
while (bp < be) {
if (alternate == 0) {
/* multiply by the 32 bit FNV magic prime mod 2^32 */ /* multiply by the 32 bit FNV magic prime mod 2^32 */
hval *= PHP_FNV_32_PRIME; hval *= PHP_FNV_32_PRIME;
/* xor the bottom with the current octet */ /* xor the bottom with the current octet */
hval ^= (uint32_t)*bp++; hval ^= (uint32_t)*bp++;
} else { }
} else {
while (bp < be) {
/* xor the bottom with the current octet */ /* xor the bottom with the current octet */
hval ^= (uint32_t)*bp++; hval ^= (uint32_t)*bp++;
@ -202,15 +203,17 @@ fnv_64_buf(void *buf, size_t len, uint64_t hval, int alternate)
/* /*
* FNV-1 hash each octet of the buffer * FNV-1 hash each octet of the buffer
*/ */
while (bp < be) {
if (alternate == 0) { if (alternate == 0) {
while (bp < be) {
/* multiply by the 64 bit FNV magic prime mod 2^64 */ /* multiply by the 64 bit FNV magic prime mod 2^64 */
hval *= PHP_FNV_64_PRIME; hval *= PHP_FNV_64_PRIME;
/* xor the bottom with the current octet */ /* xor the bottom with the current octet */
hval ^= (uint64_t)*bp++; hval ^= (uint64_t)*bp++;
} else { }
} else {
while (bp < be) {
/* xor the bottom with the current octet */ /* xor the bottom with the current octet */
hval ^= (uint64_t)*bp++; hval ^= (uint64_t)*bp++;