[Support] Use unsigned char for xxHash 64-bit
authorFangrui Song <maskray@google.com>
Fri, 27 Jul 2018 16:01:09 +0000 (16:01 +0000)
committerFangrui Song <maskray@google.com>
Fri, 27 Jul 2018 16:01:09 +0000 (16:01 +0000)
Before, the last 3 bytes were char-signedness dependent.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338128 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/xxhash.cpp

index a7d990bf6a4b26b66cd060cacb22c83a52ab667b..df643f9bd6397af8bcafffe28bad3e2349d01677 100644 (file)
@@ -71,12 +71,12 @@ static uint64_t mergeRound(uint64_t Acc, uint64_t Val) {
 uint64_t llvm::xxHash64(StringRef Data) {
   size_t Len = Data.size();
   uint64_t Seed = 0;
-  const char *P = Data.data();
-  const char *const BEnd = P + Len;
+  const unsigned char *P = Data.bytes_begin();
+  const unsigned char *const BEnd = Data.bytes_end();
   uint64_t H64;
 
   if (Len >= 32) {
-    const char *const Limit = BEnd - 32;
+    const unsigned char *const Limit = BEnd - 32;
     uint64_t V1 = Seed + PRIME64_1 + PRIME64_2;
     uint64_t V2 = Seed + PRIME64_2;
     uint64_t V3 = Seed + 0;