// This is the Hash128to64 function from Google's cityhash (available
// under the MIT License). We use it to reduce multiple 64 bit hashes
// into a single hash.
-inline size_t hash_128_to_64(const size_t upper, const size_t lower) {
+inline uint64_t hash_128_to_64(const uint64_t upper, const uint64_t lower) {
// Murmur-inspired hashing.
- const size_t kMul = 0x9ddfea08eb382d69ULL;
- size_t a = (lower ^ upper) * kMul;
+ const uint64_t kMul = 0x9ddfea08eb382d69ULL;
+ uint64_t a = (lower ^ upper) * kMul;
a ^= (a >> 47);
- size_t b = (upper ^ a) * kMul;
+ uint64_t b = (upper ^ a) * kMul;
b ^= (b >> 47);
b *= kMul;
return b;
}
inline uint32_t fnv32_buf(const void* buf,
- int n,
+ size_t n,
uint32_t hash = FNV_32_HASH_START) {
const char* char_buf = reinterpret_cast<const char*>(buf);
- for (int i = 0; i < n; ++i) {
+ for (size_t i = 0; i < n; ++i) {
hash += (hash << 1) + (hash << 4) + (hash << 7) +
(hash << 8) + (hash << 24);
hash ^= char_buf[i];
}
inline uint64_t fnv64_buf(const void* buf,
- int n,
+ size_t n,
uint64_t hash = FNV_64_HASH_START) {
const char* char_buf = reinterpret_cast<const char*>(buf);
- for (int i = 0; i < n; ++i) {
+ for (size_t i = 0; i < n; ++i) {
hash += (hash << 1) + (hash << 4) + (hash << 5) + (hash << 7) +
(hash << 8) + (hash << 40);
hash ^= char_buf[i];
#define get16bits(d) (*((const uint16_t*) (d)))
-inline uint32_t hsieh_hash32_buf(const void* buf, int len) {
+inline uint32_t hsieh_hash32_buf(const void* buf, size_t len) {
const char* s = reinterpret_cast<const char*>(buf);
- uint32_t hash = len;
+ uint32_t hash = static_cast<uint32_t>(len);
uint32_t tmp;
- int rem;
+ size_t rem;
if (len <= 0 || buf == 0) {
return 0;