From 95bb02c8a8b8599d44e1b494c14ede00c6098e62 Mon Sep 17 00:00:00 2001 From: Douglas Crosher Date: Thu, 3 Oct 2013 10:11:18 +1000 Subject: [PATCH] Bug 923328 - Ionmonkey: fix float32 hash function. r=terrence --- js/public/HashTable.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/public/HashTable.h b/js/public/HashTable.h index 9b0d32d87d5..bfad076f6e5 100644 --- a/js/public/HashTable.h +++ b/js/public/HashTable.h @@ -575,6 +575,19 @@ struct DefaultHasher } }; +template <> +struct DefaultHasher +{ + typedef float Lookup; + static HashNumber hash(float f) { + JS_STATIC_ASSERT(sizeof(HashNumber) == 4); + return HashNumber(mozilla::BitwiseCast(f)); + } + static bool match(float lhs, float rhs) { + return mozilla::BitwiseCast(lhs) == mozilla::BitwiseCast(rhs); + } +}; + /*****************************************************************************/ // Both HashMap and HashSet are implemented by a single HashTable that is even