ssxre/bxstringhash.cpp

16 lines
322 B
C++
Raw Normal View History

2023-07-22 03:35:32 -04:00
// BX code uses the [PJW Hash](https://en.wikipedia.org/wiki/PJW_hash_function) function.
uint32_t bxStringHash(const char* in) {
uint32_t hash = 0;
uint32_t high = 0;
while(*in) {
hash = (hash << 4) + *in++;
if(high = hash & 0xf0000000)
hash ^= high >> 23;
hash &= ~high;
}
return hash;
}