]> git.saurik.com Git - redis.git/commitdiff
Skip object encoding where it doesn't make sense
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Sun, 17 Oct 2010 16:09:23 +0000 (18:09 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Sun, 17 Oct 2010 16:13:31 +0000 (18:13 +0200)
src/config.c
src/pubsub.c
src/redis.c

index ff4c130f40044b3ed62c85b93534f63c5fc5ef11..c979162bc535ae7c274756023c64645b04d7efaa 100644 (file)
@@ -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);
index 23b0ceb0bcece1db097828047f19f680133c40f5..2bd3d05807071aa7853d3c478a5318aec475389b 100644 (file)
@@ -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);
 }
index a3f04f1126e3b0ca83802c921579f30b415e0a18..62a54b84304567dd4c7791d777f014e1c7d59e30 100644 (file)
@@ -1007,7 +1007,6 @@ void pingCommand(redisClient *c) {
 }
 
 void echoCommand(redisClient *c) {
-    c->argv[1] = tryObjectEncoding(c->argv[1]);
     addReplyBulk(c,c->argv[1]);
 }