diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2017-12-09 12:40:43 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2017-12-09 12:40:43 +0100 |
commit | ade860f463dc04be3149e6367b77af5a5f50de31 (patch) | |
tree | bab89811fbc353e59f925e3f08d7f4c3413aef3c /util.c | |
parent | 73341a5cf74d960348dfed62b3dd2d7a72f61495 (diff) |
sfeed_mbox: move murmur to this file, cleanup
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 52 |
1 files changed, 0 insertions, 52 deletions
@@ -267,55 +267,3 @@ printutf8pad(FILE *fp, const char *s, size_t len, int pad) for (; col < len; col++) putc(pad, fp); } - -uint32_t -murmur3_32(const char *key, uint32_t len, uint32_t seed) -{ - static const uint32_t c1 = 0xcc9e2d51; - static const uint32_t c2 = 0x1b873593; - static const uint32_t r1 = 15; - static const uint32_t r2 = 13; - static const uint32_t m = 5; - static const uint32_t n = 0xe6546b64; - uint32_t hash = seed; - const int nblocks = len / 4; - const uint32_t *blocks = (const uint32_t *) key; - int i; - uint32_t k, k1; - const uint8_t *tail; - - for (i = 0; i < nblocks; i++) { - k = blocks[i]; - k *= c1; - k = ROT32(k, r1); - k *= c2; - - hash ^= k; - hash = ROT32(hash, r2) * m + n; - } - tail = (const uint8_t *) (key + nblocks * 4); - - k1 = 0; - switch (len & 3) { - case 3: - k1 ^= tail[2] << 16; - case 2: - k1 ^= tail[1] << 8; - case 1: - k1 ^= tail[0]; - - k1 *= c1; - k1 = ROT32(k1, r1); - k1 *= c2; - hash ^= k1; - } - - hash ^= len; - hash ^= (hash >> 16); - hash *= 0x85ebca6b; - hash ^= (hash >> 13); - hash *= 0xc2b2ae35; - hash ^= (hash >> 16); - - return hash; -} |