FastLED 3.9.15
Loading...
Searching...
No Matches

◆ MurmurHash3_x86_32()

static u32 fl::MurmurHash3_x86_32 ( const void * key,
fl::size len,
u32 seed = 0 )
inlinestatic

Definition at line 22 of file hash.h.

23 {
24
26 FL_DISABLE_WARNING_IMPLICIT_FALLTHROUGH;
27
28 const fl::u8 *data = static_cast<const fl::u8 *>(key);
29 const int nblocks = int(len / 4);
30
31 u32 h1 = seed;
32 const u32 c1 = 0xcc9e2d51;
33 const u32 c2 = 0x1b873593;
34
35 // body
36 const u32 *blocks = reinterpret_cast<const u32 *>(data); // ok reinterpret cast
37 for (int i = 0; i < nblocks; ++i) {
38 u32 k1 = blocks[i];
39 k1 *= c1;
40 k1 = (k1 << 15) | (k1 >> 17);
41 k1 *= c2;
42
43 h1 ^= k1;
44 h1 = (h1 << 13) | (h1 >> 19);
45 h1 = h1 * 5 + 0xe6546b64;
46 }
47
48 // tail
49 const fl::u8 *tail = data + (nblocks * 4);
50 u32 k1 = 0;
51 switch (len & 3) {
52 case 3:
53 k1 ^= u32(tail[2]) << 16;
54 case 2:
55 k1 ^= u32(tail[1]) << 8;
56 case 1:
57 k1 ^= u32(tail[0]);
58 k1 *= c1;
59 k1 = (k1 << 15) | (k1 >> 17);
60 k1 *= c2;
61 h1 ^= k1;
62 }
63
64 // finalization
65 h1 ^= u32(len);
66 // fmix32
67 h1 ^= h1 >> 16;
68 h1 *= 0x85ebca6b;
69 h1 ^= h1 >> 13;
70 h1 *= 0xc2b2ae35;
71 h1 ^= h1 >> 16;
72
73 return h1;
74
76}
unsigned char u8
Definition s16x16x4.h:132
unsigned char u8
Definition stdint.h:131
#define FL_DISABLE_WARNING_PUSH
#define FL_DISABLE_WARNING_POP

References FL_DISABLE_WARNING_POP, and FL_DISABLE_WARNING_PUSH.

Referenced by fl::FastHash< vec2< T > >::operator()(), fl::Hash< audio::fft::Args >::operator()(), fl::Hash< double >::operator()(), fl::Hash< fl::string >::operator()(), fl::Hash< fl::string_view >::operator()(), fl::Hash< Key >::operator()(), fl::Hash< T * >::operator()(), and fl::Hash< vec2< T > >::operator()().

+ Here is the caller graph for this function: