79 lines · 1.4 KB · C
RawDownload
#include "inc/priv.h"#include "inc/hashing.h"#if defined(USE_XXHASH)#include <xxhash.h>#else#include "spooky.h"#endif sl_vnextipow2(sl_v a){	a |= a >> 1;	a |= a >> 2;	a |= a >> 4;	a |= a >> 8;	a |= a >> 16;#if defined(BITS64)	a |= a >> 32;#endif	a++;	assert(a != 0);	return a;} sl_vinthash(sl_v a){#if defined(BITS64)	a = (~a) + (a << 21); // a = (a << 21) - a - 1;	a = a ^ (a >> 24);	a = (a + (a << 3)) + (a << 8); // a * 265	a = a ^ (a >> 14);	a = (a + (a << 2)) + (a << 4); // a * 21	a = a ^ (a >> 28);	a = a + (a << 31);#else	a = (a+0x7ed55d16) + (a<<12);	a = (a^0xc761c23c) ^ (a>>19);	a = (a+0x165667b1) + (a<<5);	a = (a+0xd3a2646c) ^ (a<<9);	a = (a+0xfd7046c5) + (a<<3);	a = (a^0xb55a4f09) ^ (a>>16);#endif	return a;} #if !defined(BITS64)u32intint64to32hash(u64int key){	key = (~key) + (key << 18); // key = (key << 18) - key - 1;	key = key ^ (key >> 31);	key = key * 21;			 // key = (key + (key << 2)) + (key << 4);	key = key ^ (key >> 11);	key = key + (key << 6);	key = key ^ (key >> 22);	return (u32int)key;}#endif u64intmemhash64(const char *buf, usize n){#if defined(USE_XXHASH)	return XXH3_64bits_withSeed(buf, n, 0xcafe8881ULL);#else	return spooky_hash64(buf, n, 0xcafe8881ULL);#endif} u32intmemhash32(const char *buf, usize n){#if defined(USE_XXHASH)	return XXH32(buf, n, 0xcafe8881U);#else	return spooky_hash32(buf, n, 0xcafe8881U);#endif}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t