Add folly::hasher support for floating point types
authorGiuseppe Ottaviano <ott@fb.com>
Sun, 26 Nov 2017 22:43:06 +0000 (14:43 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sun, 26 Nov 2017 23:01:00 +0000 (15:01 -0800)
commit13e576ac96bfc04b412d8fc54ad5abe6f2552986
tree0e5154a8af1dc360b45e235b76c7412e25b11c98
parentc45f2aa595428c80bbd34b70925c236f83dc6231
Add folly::hasher support for floating point types

Summary:
Move `folly::hasher` closer to feature parity with `std::hash`.
This is in order to replace some instances of `folly::hash::hash_combine(...)` with `folly::Hash()(...)` (`std::hash` is the identity for integers, which makes it an unsafe default for more sophisticated hash data structures, including open-addressing hash tables).

The implementation is similar to `libstdc++`'s implementation, in that we handle separately the `0` case, because `0` and `-0` have different binary representations but are equal according to `operator==`, and hash the bytes otherwise. It is probably a little faster than `libstdc++`'s implementation, that delegates a out-of-line Murmur hash routine for arbitrary buffers, while this uses a minimal inlineable machine word hashing routine.

Reviewed By: yfeldblum

Differential Revision: D6410713

fbshipit-source-id: 86d9e4ed8da04fffe283949825852e539ec7d5cf
folly/hash/Hash.h
folly/hash/test/HashTest.cpp