macro option for an intentionally-bad hash function for testing purposes

This commit is contained in:
dzaima 2023-11-29 18:58:18 +02:00
parent a5ce138385
commit 6573232694
2 changed files with 8 additions and 1 deletions

View File

@ -18,7 +18,11 @@ NOINLINE u64 bqn_hashObj(B x, const u64 secret[4]) { // TODO manual separation o
void* data;
u64 bytes;
switch(xe) { default: UD;
case el_bit: bcl(x,xia); bytes = (xia+7)>>3; data = bitarr_ptr(x); break;
case el_bit:
#if TEST_BAD_HASH
if (xia>=64) return *(u64*)bitarr_ptr(x);
#endif
bcl(x,xia); bytes = (xia+7)>>3; data = bitarr_ptr(x); break;
case el_i8: case el_c8: bytes = xia*1; data = tyany_ptr(x); break;
case el_i16: case el_c16: bytes = xia*2; data = tyany_ptr(x); break;
case el_i32: case el_c32: bytes = xia*4; data = tyany_ptr(x); break;

View File

@ -18,6 +18,9 @@ u64 bqn_hashObj(B x, const u64 secret[4]);
static u64 bqn_hash(B x, const u64 secret[4]) { // doesn't consume
u64 h;
if (LIKELY(x.f==x.f)) {
#if TEST_BAD_HASH
return (u64)x.f;
#endif
h = m_f64(x.f+0).u;
} else if (isVal(x)) {
return bqn_hashObj(x, secret);