summaryrefslogtreecommitdiff
path: root/core/templates/hashfuncs.h
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-10-12 22:38:39 +0200
committerGitHub <noreply@github.com>2021-10-12 22:38:39 +0200
commit6f1d2133bb2b77048bf13a8180f57bff1a747226 (patch)
treef127eab7ffbf14cddeb26d6c89d09d642086c1ff /core/templates/hashfuncs.h
parent7494d54e04650bd47e2a49374dae3e87b715d2d2 (diff)
parent1f38b00242392d96c71714975a30c2f1cf66e38d (diff)
Merge pull request #52495 from kdiduk/issue-52491-fix-value-conversion-in-hashfuncs-header
#52491 Cosmetic: fix type cast so that it matches return value type
Diffstat (limited to 'core/templates/hashfuncs.h')
-rw-r--r--core/templates/hashfuncs.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/templates/hashfuncs.h b/core/templates/hashfuncs.h
index 2e932f9f26..c1a7c4146e 100644
--- a/core/templates/hashfuncs.h
+++ b/core/templates/hashfuncs.h
@@ -74,6 +74,13 @@ static inline uint32_t hash_djb2_one_32(uint32_t p_in, uint32_t p_prev = 5381) {
return ((p_prev << 5) + p_prev) + p_in;
}
+/**
+ * Thomas Wang's 64-bit to 32-bit Hash function:
+ * https://web.archive.org/web/20071223173210/https:/www.concentric.net/~Ttwang/tech/inthash.htm
+ *
+ * @param p_int - 64-bit unsigned integer key to be hashed
+ * @return unsigned 32-bit value representing hashcode
+ */
static inline uint32_t hash_one_uint64(const uint64_t p_int) {
uint64_t v = p_int;
v = (~v) + (v << 18); // v = (v << 18) - v - 1;
@@ -82,7 +89,7 @@ static inline uint32_t hash_one_uint64(const uint64_t p_int) {
v = v ^ (v >> 11);
v = v + (v << 6);
v = v ^ (v >> 22);
- return (int)v;
+ return uint32_t(v);
}
static inline uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev = 5381) {