diff options
author | 2017-07-11 11:10:37 -0700 | |
---|---|---|
committer | 2017-07-11 11:14:26 -0700 | |
commit | c1b6f48808fabc98797d21a78a14dd9ac2ca9d8a (patch) | |
tree | 5bfd6c8e48593c1e3a9e9bef921d8c2bd86da9c0 /tensorflow/core/lib/gtl/flatmap.h | |
parent | 082ede6cec7787dc5e9422a37afdf9ad5d88c5e2 (diff) |
Switch FlatMap and FlatSet to use a non-identity hasher for pointers.
Previously the default hasher for FlatMap and FlatSet used std::hash by
default. Most stdlibs' std::hash for pointers is the identity function.
This works for std::unordered_{set,map} because those are prime-sized
hashtables. But FlatSet and FlatMap are power-of-two-sized, and so the
identity function is bad, bad news.
This change also switches us to use Hash64 for strings, rather than
std::hash.
PiperOrigin-RevId: 161553663
Diffstat (limited to 'tensorflow/core/lib/gtl/flatmap.h')
-rw-r--r-- | tensorflow/core/lib/gtl/flatmap.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tensorflow/core/lib/gtl/flatmap.h b/tensorflow/core/lib/gtl/flatmap.h index 19e1eb5c3b..e92083fecf 100644 --- a/tensorflow/core/lib/gtl/flatmap.h +++ b/tensorflow/core/lib/gtl/flatmap.h @@ -22,6 +22,7 @@ limitations under the License. #include <iterator> #include <utility> #include "tensorflow/core/lib/gtl/flatrep.h" +#include "tensorflow/core/lib/hash/hash.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/types.h" @@ -33,7 +34,7 @@ namespace gtl { // The map is implemented using an open-addressed hash table. A // single array holds entire map contents and collisions are resolved // by probing at a sequence of locations in the array. -template <typename Key, typename Val, class Hash = std::hash<Key>, +template <typename Key, typename Val, class Hash = hash<Key>, class Eq = std::equal_to<Key>> class FlatMap { private: |