mirror of
https://github.com/luksamuk/engine-psx.git
synced 2025-04-28 13:28:02 +03:00
Remove unused cityhash32 code
This commit is contained in:
parent
dff43d7654
commit
d730a6a119
1 changed files with 0 additions and 97 deletions
97
src/util.c
97
src/util.c
|
@ -118,100 +118,3 @@ adler32(const char *s)
|
|||
}
|
||||
return (b << 16) | a;
|
||||
}
|
||||
|
||||
/* cityhash32 */
|
||||
|
||||
#define ROTATE32(v, n) (n == 0 ? v : ((v >> n) | (v << (32 - n))))
|
||||
// This macro expects a big endian value, which we already have
|
||||
#define FETCH32(p) ((uint32_t)(*p))
|
||||
|
||||
#define MAGIC_C1 0xcc9e2d51
|
||||
#define MAGIC_C2 0x1b873593
|
||||
|
||||
uint32_t
|
||||
_ch32_mur(uint32_t a, uint32_t h)
|
||||
{
|
||||
a *= MAGIC_C1;
|
||||
a = ROTATE32(a, 17);
|
||||
a *= MAGIC_C2;
|
||||
h ^= a;
|
||||
h = ROTATE32(h, 19);
|
||||
return h * 5 + 0xe6546b64;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
_ch32_fmix(uint32_t h)
|
||||
{
|
||||
h ^= h >> 16;
|
||||
h *= 0x85ebca6b;
|
||||
h ^= h >> 13;
|
||||
h *= 0xc2b2ae35;
|
||||
h ^= h >> 16;
|
||||
return h;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
_ch32_0_4(const char *s, size_t len)
|
||||
{
|
||||
uint32_t b = 0, c = 9;
|
||||
for(size_t i = 0; i < len; i++) {
|
||||
int8_t v = (int8_t)s[i];
|
||||
b = b * MAGIC_C1 + ((uint32_t)v);
|
||||
c ^= b;
|
||||
}
|
||||
return _ch32_fmix(_ch32_mur(b, _ch32_mur((uint32_t)len, c)));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
_ch32_5_12(const char *s, size_t len)
|
||||
{
|
||||
uint32_t
|
||||
a = (uint32_t)len,
|
||||
b = a * 5,
|
||||
c = 9,
|
||||
d = b;
|
||||
a += FETCH32(s);
|
||||
b += FETCH32(s + len - 4);
|
||||
c += FETCH32(s + ((len >> 1) & 4));
|
||||
return _ch32_fmix(_ch32_mur(c, _ch32_mur(b, _ch32_mur(a, d))));
|
||||
}
|
||||
|
||||
uint32_t
|
||||
_ch32_13_24(const char *s, size_t len)
|
||||
{
|
||||
uint32_t
|
||||
a = FETCH32(s - 4 + (len >> 1)),
|
||||
b = FETCH32(s + 4),
|
||||
c = FETCH32(s + len - 8),
|
||||
d = FETCH32(s + (len >> 1)),
|
||||
e = FETCH32(s),
|
||||
f = FETCH32(s + len - 4),
|
||||
h = (uint32_t)len;
|
||||
return _ch32_fmix(
|
||||
_ch32_mur(
|
||||
f,
|
||||
_ch32_mur(
|
||||
e,
|
||||
_ch32_mur(
|
||||
d,
|
||||
_ch32_mur(
|
||||
c,
|
||||
_ch32_mur(
|
||||
b,
|
||||
_ch32_mur(a, h)))))));
|
||||
}
|
||||
|
||||
// Perform cityhash32 on a string. Notice that this quick variant
|
||||
// expects a string below 24 characters.
|
||||
// Source:
|
||||
// https://github.com/google/cityhash/blob/f5dc54147fcce12cefd16548c8e760d68ac04226/src/city.cc#L189
|
||||
uint32_t
|
||||
cityhash32_sub24(const char *s)
|
||||
{
|
||||
size_t len = strlen(s);
|
||||
len = (len > 24) ? 24 : len;
|
||||
return (len <= 12)
|
||||
? (len <= 4 ? _ch32_0_4(s, len) : _ch32_5_12(s, len))
|
||||
: _ch32_13_24(s, len);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue