diff options
author | joshua stein <jcs@jcs.org> | 2020-02-17 13:19:28 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-25 15:32:58 +0100 |
commit | 7e6ac544f77a701eb7e70b6d21338ad38dc5781a (patch) | |
tree | 4f3a210cba5c84cde6626223527edcfa82969dbe /AK/HashFunctions.h | |
parent | 32e6453b0bd2992c186831f743e43d8a472362a3 (diff) | |
download | serenity-7e6ac544f77a701eb7e70b6d21338ad38dc5781a.zip |
AK: Add ptr_hash to use int_hash or u64_hash depending on pointer size
Diffstat (limited to 'AK/HashFunctions.h')
-rw-r--r-- | AK/HashFunctions.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/AK/HashFunctions.h b/AK/HashFunctions.h index 9fb365c744..caad086d76 100644 --- a/AK/HashFunctions.h +++ b/AK/HashFunctions.h @@ -50,3 +50,11 @@ inline unsigned u64_hash(u64 key) u32 last = key >> 32; return pair_int_hash(first, last); } + +inline unsigned ptr_hash(uintptr_t ptr) +{ + if constexpr(sizeof(ptr) == 8) + return u64_hash((u64)ptr); + else + return int_hash((u32)ptr); +} |