From a375b077cc1da6afee6497749e4e3512caa757c7 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Sun, 17 Oct 2010 18:09:23 +0200 Subject: [PATCH] Skip object encoding where it doesn't make sense --- src/config.c | 14 ++++++-------- src/pubsub.c | 1 - src/redis.c | 1 - 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/config.c b/src/config.c index ff4c130f..c979162b 100644 --- a/src/config.c +++ b/src/config.c @@ -225,8 +225,11 @@ loaderr: *----------------------------------------------------------------------------*/ void configSetCommand(redisClient *c) { - robj *o = getDecodedObject(c->argv[3]); + robj *o; long long ll; + redisAssert(c->argv[2]->encoding == REDIS_ENCODING_RAW); + redisAssert(c->argv[3]->encoding == REDIS_ENCODING_RAW); + o = c->argv[3]; if (!strcasecmp(c->argv[2]->ptr,"dbfilename")) { zfree(server.dbfilename); @@ -273,7 +276,6 @@ void configSetCommand(redisClient *c) { if (startAppendOnly() == REDIS_ERR) { addReplyError(c, "Unable to turn on AOF. Check server logs."); - decrRefCount(o); return; } } @@ -315,10 +317,8 @@ void configSetCommand(redisClient *c) { } else { addReplyErrorFormat(c,"Unsupported CONFIG parameter: %s", (char*)c->argv[2]->ptr); - decrRefCount(o); return; } - decrRefCount(o); addReply(c,shared.ok); return; @@ -326,14 +326,14 @@ badfmt: /* Bad format errors */ addReplyErrorFormat(c,"Invalid argument '%s' for CONFIG SET '%s'", (char*)o->ptr, (char*)c->argv[2]->ptr); - decrRefCount(o); } void configGetCommand(redisClient *c) { - robj *o = getDecodedObject(c->argv[2]); + robj *o = c->argv[2]; void *replylen = addDeferredMultiBulkLength(c); char *pattern = o->ptr; int matches = 0; + redisAssert(o->encoding == REDIS_ENCODING_RAW); if (stringmatch(pattern,"dbfilename",0)) { addReplyBulkCString(c,"dbfilename"); @@ -405,12 +405,10 @@ void configGetCommand(redisClient *c) { sdsfree(buf); matches++; } - decrRefCount(o); setDeferredMultiBulkLength(c,replylen,matches*2); } void configCommand(redisClient *c) { - c->argv[c->argc-1] = tryObjectEncoding(c->argv[c->argc-1]); if (!strcasecmp(c->argv[1]->ptr,"set")) { if (c->argc != 4) goto badarity; configSetCommand(c); diff --git a/src/pubsub.c b/src/pubsub.c index 23b0ceb0..2bd3d058 100644 --- a/src/pubsub.c +++ b/src/pubsub.c @@ -262,7 +262,6 @@ void punsubscribeCommand(redisClient *c) { } void publishCommand(redisClient *c) { - c->argv[2] = tryObjectEncoding(c->argv[2]); int receivers = pubsubPublishMessage(c->argv[1],c->argv[2]); addReplyLongLong(c,receivers); } diff --git a/src/redis.c b/src/redis.c index a3f04f11..62a54b84 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1007,7 +1007,6 @@ void pingCommand(redisClient *c) { } void echoCommand(redisClient *c) { - c->argv[1] = tryObjectEncoding(c->argv[1]); addReplyBulk(c,c->argv[1]); } -- 2.47.2