ssxre/bxstringhash.cpp

16 lines
322 B
C++

// 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;
}