diff options
author | 2017-11-20 14:11:14 -0800 | |
---|---|---|
committer | 2017-11-20 14:18:27 -0800 | |
commit | dd8ad028e79005377d326a02fa77f655a0f62699 (patch) | |
tree | 9ef88a71780475d01092b37245784819e4231e15 /tensorflow/core/lib/core | |
parent | 74faf5003bb3d0ed885a96b7a517072465d9e579 (diff) |
Moved tensorflow::StringPiece::Hasher out of tensorflow::StringPiece (to tensorflow::StringPieceHasher) and replaced it with an alias.
This will allow tensorflow::StringPiece to be more easily replaced with absl::string_view (which does not contain a Hasher struct) after all references to tensorflow::StringPiece::Hasher are removed.
PiperOrigin-RevId: 176414198
Diffstat (limited to 'tensorflow/core/lib/core')
-rw-r--r-- | tensorflow/core/lib/core/stringpiece.cc | 2 | ||||
-rw-r--r-- | tensorflow/core/lib/core/stringpiece.h | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/tensorflow/core/lib/core/stringpiece.cc b/tensorflow/core/lib/core/stringpiece.cc index 984f4404ce..29b727fc44 100644 --- a/tensorflow/core/lib/core/stringpiece.cc +++ b/tensorflow/core/lib/core/stringpiece.cc @@ -21,7 +21,7 @@ limitations under the License. namespace tensorflow { -size_t StringPiece::Hasher::operator()(StringPiece s) const { +size_t StringPieceHasher::operator()(StringPiece s) const { return Hash64(s.data(), s.size()); } diff --git a/tensorflow/core/lib/core/stringpiece.h b/tensorflow/core/lib/core/stringpiece.h index 94f4a377f1..b2c6842151 100644 --- a/tensorflow/core/lib/core/stringpiece.h +++ b/tensorflow/core/lib/core/stringpiece.h @@ -35,6 +35,8 @@ limitations under the License. namespace tensorflow { +struct StringPieceHasher; + class StringPiece { public: typedef size_t size_type; @@ -103,9 +105,7 @@ class StringPiece { StringPiece substr(size_t pos, size_t n = npos) const; - struct Hasher { - size_t operator()(StringPiece arg) const; - }; + using Hasher = ::tensorflow::StringPieceHasher; // Return a string that contains the copy of the referenced data. std::string ToString() const { return std::string(data_, size_); } @@ -133,6 +133,10 @@ class StringPiece { // Intentionally copyable }; +struct StringPieceHasher { + size_t operator()(StringPiece s) const; +}; + inline bool operator==(StringPiece x, StringPiece y) { return ((x.size() == y.size()) && (memcmp(x.data(), y.data(), x.size()) == 0)); |