diff options
author | Andreas Haas <Hinsbart@users.noreply.github.com> | 2017-04-14 17:51:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-14 17:51:05 +0200 |
commit | 6871ec708fb6475027055a3b54c31bacfdb0339d (patch) | |
tree | 22ac043cebe0003c524064385e095fecfd53854e | |
parent | 4e7c5eb498f338e6157665976b975016bd54505c (diff) | |
parent | 8ff6e538336135837630e313027826e9bd8d036e (diff) |
Merge pull request #8393 from hpvb/fix-8081
Correct Variant::hash_compare()
-rw-r--r-- | core/hashfuncs.h | 18 | ||||
-rw-r--r-- | core/variant.cpp | 2 |
2 files changed, 1 insertions, 19 deletions
diff --git a/core/hashfuncs.h b/core/hashfuncs.h index fbd2e161b3..8392984565 100644 --- a/core/hashfuncs.h +++ b/core/hashfuncs.h @@ -81,24 +81,6 @@ static inline uint32_t hash_one_uint64(const uint64_t p_int) { return (int)v; } -static inline uint32_t hash_djb2_one_float(float p_in, uint32_t p_prev = 5381) { - union { - float f; - uint32_t i; - } u; - - // Normalize +/- 0.0 and NaN values so they hash the same. - if (p_in == 0.0f) - u.f = 0.0; - else if (Math::is_nan(p_in)) - u.f = Math_NAN; - else - u.f = p_in; - - return ((p_prev << 5) + p_prev) + u.i; -} - -// Overload for real_t size changes static inline uint32_t hash_djb2_one_float(double p_in, uint32_t p_prev = 5381) { union { double d; diff --git a/core/variant.cpp b/core/variant.cpp index 6e675d07de..67ce8af483 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -2839,7 +2839,7 @@ uint32_t Variant::hash() const { } #define hash_compare_scalar(p_lhs, p_rhs) \ - ((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) == Math::is_nan(p_rhs)) + ((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs)) #define hash_compare_vector2(p_lhs, p_rhs) \ (hash_compare_scalar((p_lhs).x, (p_rhs).x)) && \ |