From: Date: Sun, 16 Mar 2008 00:37:11 +0000 (-0700) Subject: Update from Tanj X-Git-Tag: 0.20~1^2~52 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=caf0d1b9dbab5d798d39d6394219e50ea73ccbd8;p=awesomized%2Flibmemcached Update from Tanj --- diff --git a/libmemcached/murmur_hash.c b/libmemcached/murmur_hash.c index ce28ec38..e673420d 100644 --- a/libmemcached/murmur_hash.c +++ b/libmemcached/murmur_hash.c @@ -11,28 +11,25 @@ uint32_t murmur_hash(char *key, size_t length) const uint32_t m= 0x5bd1e995; const int r= 16; uint32_t h= length * m; + uint32_t k = 0; while(length >= 4) { - uint32_t k = *(uint32_t*)key; + k = *(uint32_t*)key; MIX(h,k,m); key += 4; length -= 4; } - if (length) + switch(length) { - uint32_t k= 0; - - switch(length) - { - case 3: k += key[2] << 16; - case 2: k += key[1] << 8; - case 1: k += key[0]; - }; - MIX(h,k,m); - } + case 3: k += key[2] << 16; + case 2: k += key[1] << 8; + case 1: k += key[0]; + MIX(h,k,m); + default: + }; h *= m; h ^= h >> 10;