mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
Don't decode object on STRLEN when not necessary
This commit is contained in:
parent
cc20906390
commit
7ecd4644e7
@ -358,7 +358,14 @@ void strlenCommand(redisClient *c) {
|
|||||||
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
|
if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
|
||||||
checkType(c,o,REDIS_STRING)) return;
|
checkType(c,o,REDIS_STRING)) return;
|
||||||
|
|
||||||
o = getDecodedObject(o);
|
if (o->encoding == REDIS_ENCODING_RAW) {
|
||||||
addReplyLongLong(c,sdslen(o->ptr));
|
addReplyLongLong(c,sdslen(o->ptr));
|
||||||
decrRefCount(o);
|
} else if (o->encoding == REDIS_ENCODING_INT) {
|
||||||
|
char llbuf[32];
|
||||||
|
int len = ll2string(llbuf,sizeof(llbuf),(long)o->ptr);
|
||||||
|
addReplyLongLong(c,len);
|
||||||
|
} else {
|
||||||
|
redisPanic("Unknown string encoding");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user