[C++] Compare last 8 bytes first in StringPiece::operator==
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 @@
 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 {
diff --git a/string_piece_test.cc b/string_piece_test.cc
index 7b253a0..0434cbe 100644
--- a/string_piece_test.cc
+++ b/string_piece_test.cc
@@ -30,4 +30,8 @@
   assert(sps.size() == 2);
   assert(sps.count(StringPiece("foo")) == 1);
   assert(sps.count(StringPiece("bar")) == 1);
+
+  assert(StringPiece("hogefugahige") == StringPiece("hogefugahige"));
+  assert(StringPiece("hogefugahoge") != StringPiece("hogefugahige"));
+  assert(StringPiece("hogefugahige") != StringPiece("higefugahige"));
 }