mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 17:40:50 +00:00
Faster version of the function hashing possibly encoded objects, leading to a general speed gain when working with Sets of integers
This commit is contained in:
parent
3c68de9b01
commit
ed9e496634
22
redis.c
22
redis.c
@ -954,10 +954,24 @@ static int dictEncObjKeyCompare(void *privdata, const void *key1,
|
|||||||
static unsigned int dictEncObjHash(const void *key) {
|
static unsigned int dictEncObjHash(const void *key) {
|
||||||
robj *o = (robj*) key;
|
robj *o = (robj*) key;
|
||||||
|
|
||||||
o = getDecodedObject(o);
|
if (o->encoding == REDIS_ENCODING_RAW) {
|
||||||
unsigned int hash = dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
|
return dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
|
||||||
decrRefCount(o);
|
} else {
|
||||||
return hash;
|
if (o->encoding == REDIS_ENCODING_INT) {
|
||||||
|
char buf[32];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = snprintf(buf,32,"%ld",(long)o->ptr);
|
||||||
|
return dictGenHashFunction((unsigned char*)buf, len);
|
||||||
|
} else {
|
||||||
|
unsigned int hash;
|
||||||
|
|
||||||
|
o = getDecodedObject(o);
|
||||||
|
hash = dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
|
||||||
|
decrRefCount(o);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sets type and expires */
|
/* Sets type and expires */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user