diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-12-14 10:31:11 +0100 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-12-14 10:42:41 +0100 |
commit | 7ecd4644e7fe48309d4b8445ec62c7fe8c0443ff (patch) | |
tree | 7d755607bd13d0d58a354a7792b4fa901ce247ef /src/t_string.c | |
parent | cc209063904ed5d86a34b2297ceac00854ff6c01 (diff) | |
download | redis-7ecd4644e7fe48309d4b8445ec62c7fe8c0443ff.tar.gz |
Don't decode object on STRLEN when not necessary
Diffstat (limited to 'src/t_string.c')
-rw-r--r-- | src/t_string.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/t_string.c b/src/t_string.c index 3b91f5e6d..d537c8b90 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -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"); + } } + |