MCPcopy Create free account
hub / github.com/Rezonality/zep / invert_shift_xor

Function invert_shift_xor

src/mcommon/string/stringutils.cpp:121–134  ·  view source on GitHub ↗

Inverts a (h ^= h >> s) operation with 8 <= s <= 16

Source from the content-addressed store, hash-verified

119
120/// Inverts a (h ^= h >> s) operation with 8 <= s <= 16
121unsigned int invert_shift_xor(unsigned int hs, unsigned int s)
122{
123 assert(s >= 8 && s <= 16);
124 unsigned hs0 = hs >> 24;
125 unsigned hs1 = (hs >> 16) & 0xff;
126 unsigned hs2 = (hs >> 8) & 0xff;
127 unsigned hs3 = hs & 0xff;
128
129 unsigned h0 = hs0;
130 unsigned h1 = hs1 ^ (h0 >> (s - 8));
131 unsigned h2 = (hs2 ^ (h0 << (16 - s)) ^ (h1 >> (s - 8))) & 0xff;
132 unsigned h3 = (hs3 ^ (h1 << (16 - s)) ^ (h2 >> (s - 8))) & 0xff;
133 return (h0 << 24) + (h1 << 16) + (h2 << 8) + h3;
134}
135
136unsigned int murmur_hash_inverse(unsigned int h, unsigned int seed)
137{

Callers 1

murmur_hash_inverseFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected