MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / FourBytes_MurmurHash2

Function FourBytes_MurmurHash2

libraries/murmur2/src/MurmurHash2.cpp:71–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void FourBytes_MurmurHash2(const unsigned char* data, IncrementalHashInfo& prev)
72{
73 if (prev.len >= 4) {
74 // Not the final mix
75 uint32_t k = *(uint32_t*)data;
76
77 k *= m;
78 k ^= k >> r;
79 k *= m;
80
81 prev.h *= m;
82 prev.h ^= k;
83
84 prev.len -= 4;
85 } else {
86 // The final mix
87
88 // Handle the last few bytes of the input array
89 switch (prev.len) {
90 case 3:
91 prev.h ^= data[2] << 16;
92 [[fallthrough]];
93 case 2:
94 prev.h ^= data[1] << 8;
95 [[fallthrough]];
96 case 1:
97 prev.h ^= data[0];
98 prev.h *= m;
99 };
100
101 // Do a few final mixes of the hash to ensure the last few
102 // bytes are well-incorporated.
103
104 prev.h ^= prev.h >> 13;
105 prev.h *= m;
106 prev.h ^= prev.h >> 15;
107
108 prev.len = 0;
109 }
110}
111
112//-----------------------------------------------------------------------------

Callers 1

MurmurHash2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected