[llvm] r338128 - [Support] Use unsigned char for xxHash 64-bit

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 27 09:01:09 PDT 2018


Author: maskray
Date: Fri Jul 27 09:01:09 2018
New Revision: 338128

URL: http://llvm.org/viewvc/llvm-project?rev=338128&view=rev
Log:
[Support] Use unsigned char for xxHash 64-bit

Before, the last 3 bytes were char-signedness dependent.

Modified:
    llvm/trunk/lib/Support/xxhash.cpp

Modified: llvm/trunk/lib/Support/xxhash.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/xxhash.cpp?rev=338128&r1=338127&r2=338128&view=diff
==============================================================================
--- llvm/trunk/lib/Support/xxhash.cpp (original)
+++ llvm/trunk/lib/Support/xxhash.cpp Fri Jul 27 09:01:09 2018
@@ -71,12 +71,12 @@ static uint64_t mergeRound(uint64_t Acc,
 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;




More information about the llvm-commits mailing list