mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +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 ||
|
||||
checkType(c,o,REDIS_STRING)) return;
|
||||
|
||||
o = getDecodedObject(o);
|
||||
addReplyLongLong(c,sdslen(o->ptr));
|
||||
decrRefCount(o);
|
||||
if (o->encoding == REDIS_ENCODING_RAW) {
|
||||
addReplyLongLong(c,sdslen(o->ptr));
|
||||
} 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…
Reference in New Issue
Block a user