mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
Make zzlLength take a ziplist argument
This commit is contained in:
parent
d4e07f1714
commit
bbfe232f60
10
src/t_zset.c
10
src/t_zset.c
@ -449,9 +449,7 @@ int zzlCompareElements(unsigned char *eptr, unsigned char *cstr, unsigned int cl
|
|||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int zzlLength(robj *zobj) {
|
unsigned int zzlLength(unsigned char *zl) {
|
||||||
unsigned char *zl = zobj->ptr;
|
|
||||||
redisAssert(zobj->encoding == REDIS_ENCODING_ZIPLIST);
|
|
||||||
return ziplistLen(zl)/2;
|
return ziplistLen(zl)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,7 +718,7 @@ unsigned long zzlDeleteRangeByRank(robj *zobj, unsigned int start, unsigned int
|
|||||||
int zsLength(robj *zobj) {
|
int zsLength(robj *zobj) {
|
||||||
int length = -1;
|
int length = -1;
|
||||||
if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
|
if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
|
||||||
length = zzlLength(zobj);
|
length = zzlLength(zobj->ptr);
|
||||||
} else if (zobj->encoding == REDIS_ENCODING_RAW) {
|
} else if (zobj->encoding == REDIS_ENCODING_RAW) {
|
||||||
length = ((zset*)zobj->ptr)->zsl->length;
|
length = ((zset*)zobj->ptr)->zsl->length;
|
||||||
} else {
|
} else {
|
||||||
@ -874,7 +872,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
|
|||||||
/* Optimize: check if the element is too large or the list becomes
|
/* Optimize: check if the element is too large or the list becomes
|
||||||
* too long *before* executing zzlInsert. */
|
* too long *before* executing zzlInsert. */
|
||||||
redisAssert(zzlInsert(zobj,ele,score) == REDIS_OK);
|
redisAssert(zzlInsert(zobj,ele,score) == REDIS_OK);
|
||||||
if (zzlLength(zobj) > server.zset_max_ziplist_entries)
|
if (zzlLength(zobj->ptr) > server.zset_max_ziplist_entries)
|
||||||
zsConvert(zobj,REDIS_ENCODING_RAW);
|
zsConvert(zobj,REDIS_ENCODING_RAW);
|
||||||
if (sdslen(ele->ptr) > server.zset_max_ziplist_value)
|
if (sdslen(ele->ptr) > server.zset_max_ziplist_value)
|
||||||
zsConvert(zobj,REDIS_ENCODING_RAW);
|
zsConvert(zobj,REDIS_ENCODING_RAW);
|
||||||
@ -965,7 +963,7 @@ void zremCommand(redisClient *c) {
|
|||||||
|
|
||||||
if ((eptr = zzlFind(zobj,ele,NULL)) != NULL) {
|
if ((eptr = zzlFind(zobj,ele,NULL)) != NULL) {
|
||||||
redisAssert(zzlDelete(zobj,eptr) == REDIS_OK);
|
redisAssert(zzlDelete(zobj,eptr) == REDIS_OK);
|
||||||
if (zzlLength(zobj) == 0) dbDelete(c->db,key);
|
if (zzlLength(zobj->ptr) == 0) dbDelete(c->db,key);
|
||||||
} else {
|
} else {
|
||||||
addReply(c,shared.czero);
|
addReply(c,shared.czero);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user