19 {
20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
22
23 const uint8_t *data = static_cast<const uint8_t *>(key);
24 const int nblocks = int(len / 4);
25
26 uint32_t h1 = seed;
27 const uint32_t c1 = 0xcc9e2d51;
28 const uint32_t c2 = 0x1b873593;
29
30
31 const uint32_t *blocks = reinterpret_cast<const uint32_t *>(data);
32 for (int i = 0; i < nblocks; ++i) {
33 uint32_t k1 = blocks[i];
34 k1 *= c1;
35 k1 = (k1 << 15) | (k1 >> 17);
36 k1 *= c2;
37
38 h1 ^= k1;
39 h1 = (h1 << 13) | (h1 >> 19);
40 h1 = h1 * 5 + 0xe6546b64;
41 }
42
43
44 const uint8_t *tail = data + (nblocks * 4);
45 uint32_t k1 = 0;
46 switch (len & 3) {
47 case 3:
48 k1 ^= uint32_t(tail[2]) << 16;
49 case 2:
50 k1 ^= uint32_t(tail[1]) << 8;
51 case 1:
52 k1 ^= uint32_t(tail[0]);
53 k1 *= c1;
54 k1 = (k1 << 15) | (k1 >> 17);
55 k1 *= c2;
56 h1 ^= k1;
57 }
58
59
60 h1 ^= uint32_t(len);
61
62 h1 ^= h1 >> 16;
63 h1 *= 0x85ebca6b;
64 h1 ^= h1 >> 13;
65 h1 *= 0xc2b2ae35;
66 h1 ^= h1 >> 16;
67
68 return h1;
69
70#pragma GCC diagnostic pop
71}