[algs] Speed up fasthash for aligned uint64_t

This commit is contained in:
Behdad Esfahbod 2023-06-23 15:31:54 -06:00
parent fc80d20cb5
commit b557a84123

View file

@ -297,10 +297,28 @@ static inline uint64_t fasthash64(const void *buf, size_t len, uint64_t seed)
uint64_t h = seed ^ (len * m);
uint64_t v;
while (pos != end) {
v = pos++->v;
h ^= mix(v);
h *= m;
#ifndef HB_OPTIMIZE_SIZE
if (((uintptr_t) pos & 7) == 0)
{
while (pos != end)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align"
v = * (const uint64_t *) (pos++);
#pragma GCC diagnostic pop
h ^= mix(v);
h *= m;
}
}
else
#endif
{
while (pos != end)
{
v = pos++->v;
h ^= mix(v);
h *= m;
}
}
pos2 = (const unsigned char*)pos;