Skip object encoding where it doesn't make sense

This commit is contained in:
Pieter Noordhuis 2010-10-17 18:09:23 +02:00
parent 19408d83a4
commit a375b077cc
3 changed files with 6 additions and 10 deletions

View 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);

View 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);
}

View 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]);
}