diff options
author | Justin Lebar <jlebar@google.com> | 2017-07-11 11:50:25 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-07-11 11:54:50 -0700 |
commit | c3322543862e14482b3e108fb1b2d466641fd714 (patch) | |
tree | 00aa9afd2f2fe5d920f16fec50b25a51ff814352 /tensorflow/core/lib/hash | |
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/hash')
-rw-r--r-- | tensorflow/core/lib/hash/hash.h | 18 |
1 files changed, 11 insertions, 7 deletions
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 |