1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:07:36 +00:00

Better int hashing. This was going to bite me sooner or later.

This commit is contained in:
Andreas Kling 2018-10-27 09:33:24 +02:00
parent ec07761d0f
commit 601d0d1739
4 changed files with 32 additions and 5 deletions

20
AK/HashFunctions.h Normal file
View file

@ -0,0 +1,20 @@
#pragma once
#include "Types.h"
inline unsigned intHash(dword key)
{
key += ~(key << 15);
key ^= (key >> 10);
key += (key << 3);
key ^= (key >> 6);
key += ~(key << 11);
key ^= (key >> 16);
return key;
}
inline unsigned pairIntHash(dword key1, dword key2)
{
return intHash((intHash(key1) * 209) ^ (intHash(key2 * 413)));
}