Using float/double as WTF hash table key is unreliable.
authorkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 14:44:53 +0000 (14:44 +0000)
committerkling@webkit.org <kling@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2012 14:44:53 +0000 (14:44 +0000)
<http://webkit.org/b/98627>

Reviewed by Geoffrey Garen.

Source/WTF:

Change FloatHash::equal() to do a bitwise compare instead of a logical compare.
This fixes a problem where the keys with different binary representation but the
same logical value (e.g 0 and -0) could block each other from being found if they
ended up in the same hash bucket.

* wtf/HashFunctions.h:
(FloatHash):
(WTF::FloatHash::hash):
(WTF::FloatHash::equal):

Tools:

Add a test case checking that using double as the hash table key type won't
have problems distinguishing between keys that are considered equal by operator==
but have different binary representations.

* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestDoubleHashTraits):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130639 268f45cc-cd09-0410-ab3c-d52691b4dbfc


No differences found