diff options
author | 2017-07-11 11:50:25 -0700 | |
---|---|---|
committer | 2017-07-11 11:54:50 -0700 | |
commit | c3322543862e14482b3e108fb1b2d466641fd714 (patch) | |
tree | 00aa9afd2f2fe5d920f16fec50b25a51ff814352 /tensorflow/core/lib | |
parent | c1b6f48808fabc98797d21a78a14dd9ac2ca9d8a (diff) |
Remove HashStr and HashStringPiece (a one-off).
Now that we have tensorflow::hash and it's the default hasher for
FlatMap and FlatSet, we can get rid of HashStr and HashStringPiece.
PiperOrigin-RevId: 161560034
Diffstat (limited to 'tensorflow/core/lib')
-rw-r--r-- | tensorflow/core/lib/gtl/flatmap_test.cc | 2 | ||||
-rw-r--r-- | tensorflow/core/lib/gtl/flatset_test.cc | 2 | ||||
-rw-r--r-- | tensorflow/core/lib/hash/hash.h | 18 |
3 files changed, 13 insertions, 9 deletions
diff --git a/tensorflow/core/lib/gtl/flatmap_test.cc b/tensorflow/core/lib/gtl/flatmap_test.cc index d8e50830e6..bb65e5357a 100644 --- a/tensorflow/core/lib/gtl/flatmap_test.cc +++ b/tensorflow/core/lib/gtl/flatmap_test.cc @@ -588,7 +588,7 @@ TEST(FlatMap, ForwardIterator) { // or destructions will show up as errors under a sanitizer or // heap checker. TEST(FlatMap, ConstructDestruct) { - FlatMap<string, string, HashStr> map; + FlatMap<string, string> map; string k1 = "the quick brown fox jumped over the lazy dog"; string k2 = k1 + k1; string k3 = k1 + k2; diff --git a/tensorflow/core/lib/gtl/flatset_test.cc b/tensorflow/core/lib/gtl/flatset_test.cc index 54def603c3..09fbbb1fb6 100644 --- a/tensorflow/core/lib/gtl/flatset_test.cc +++ b/tensorflow/core/lib/gtl/flatset_test.cc @@ -485,7 +485,7 @@ TEST(FlatSet, ForwardIterator) { // or destructions will show up as errors under a sanitizer or // heap checker. TEST(FlatSet, ConstructDestruct) { - FlatSet<string, HashStr> set; + FlatSet<string> set; string k1 = "the quick brown fox jumped over the lazy dog"; string k2 = k1 + k1; string k3 = k1 + k2; diff --git a/tensorflow/core/lib/hash/hash.h b/tensorflow/core/lib/hash/hash.h index b45391fac5..73b7c94d1f 100644 --- a/tensorflow/core/lib/hash/hash.h +++ b/tensorflow/core/lib/hash/hash.h @@ -23,6 +23,7 @@ limitations under the License. #include <string> +#include "tensorflow/core/lib/core/stringpiece.h" #include "tensorflow/core/platform/types.h" namespace tensorflow { @@ -42,12 +43,6 @@ inline uint64 Hash64Combine(uint64 a, uint64 b) { return a ^ (b + 0x9e3779b97f4a7800ULL + (a << 10) + (a >> 4)); } -struct HashStr { - size_t operator()(const string& s) const { - return static_cast<size_t>(Hash64(s)); - } -}; - // Hash functor suitable for use with power-of-two sized hashtables. Use // instead of std::hash<T>. // @@ -70,7 +65,16 @@ struct hash<T*> { template <> struct hash<string> { - size_t operator()(const string& s) const { return HashStr()(s); } + size_t operator()(const string& s) const { + return static_cast<size_t>(Hash64(s)); + } +}; + +template <> +struct hash<StringPiece> { + size_t operator()(StringPiece sp) const { + return static_cast<size_t>(Hash64(sp.data(), sp.size())); + } }; } // namespace tensorflow |