X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FHash.h;h=e04cf8cf48768a1e474de15d904642b5a3e0efa1;hb=2f5c6c3e446d6b98398dc5aeaf0e13ec888e1726;hp=0cc326a42bb64da68cf6a97b1427a22b081104b0;hpb=9a5abb71489597c37882f04a077880ab598d9cbc;p=folly.git diff --git a/folly/Hash.h b/folly/Hash.h index 0cc326a4..e04cf8cf 100644 --- a/folly/Hash.h +++ b/folly/Hash.h @@ -42,12 +42,12 @@ namespace folly { namespace hash { // 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; @@ -217,11 +217,11 @@ inline uint32_t fnv32(const char* s, } 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(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]; @@ -246,11 +246,11 @@ inline uint64_t fnv64(const char* s, } 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(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]; @@ -269,11 +269,11 @@ inline uint64_t fnv64(const std::string& str, #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(buf); - uint32_t hash = len; + uint32_t hash = static_cast(len); uint32_t tmp; - int rem; + size_t rem; if (len <= 0 || buf == 0) { return 0;