diff options
| author | Shinichiro Hamaji <hamaji@google.com> | 2016-02-29 20:07:39 +0900 |
|---|---|---|
| committer | Shinichiro Hamaji <hamaji@google.com> | 2016-02-29 20:07:39 +0900 |
| commit | 505d0d2b02791d1ab86df0bfa9c8726ba32026f9 (patch) | |
| tree | cb2662f728c9eedcd378e6bffdfb437d8dd4d291 /string_piece.cc | |
| parent | 086b17663573f0d2742c534885a787c6d98216b9 (diff) | |
Revert "Revert "Merge remote-tracking branch 'aosp/upstream'""
This reverts commit 086b17663573f0d2742c534885a787c6d98216b9.
Diffstat (limited to 'string_piece.cc')
| -rw-r--r-- | string_piece.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/string_piece.cc b/string_piece.cc index 78de4ed..d287616 100644 --- a/string_piece.cc +++ b/string_piece.cc @@ -21,6 +21,7 @@ #include <ctype.h> #include <limits.h> +#include <stdint.h> #include <algorithm> #include <ostream> @@ -32,8 +33,15 @@ typedef StringPiece::size_type size_type; bool operator==(const StringPiece& x, const StringPiece& y) { if (x.size() != y.size()) return false; - - return StringPiece::wordmemcmp(x.data(), y.data(), x.size()) == 0; + size_t len = x.size(); + if (len >= sizeof(uint64_t)) { + len -= sizeof(uint64_t); + uint64_t xt = *reinterpret_cast<const uint64_t*>(x.data() + len); + uint64_t yt = *reinterpret_cast<const uint64_t*>(y.data() + len); + if (xt != yt) + return false; + } + return StringPiece::wordmemcmp(x.data(), y.data(), len) == 0; } void StringPiece::CopyToString(std::string* target) const { |
