X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/cc7c4158bc9c584b91560e9bf3dff51a9316c9b3..ac1f6fd07a15ac7a14f27b8a5f4b5fb3dc6cf8ac:/src/sort.c diff --git a/src/sort.c b/src/sort.c index a44a6d63..e4fe130c 100644 --- a/src/sort.c +++ b/src/sort.c @@ -199,6 +199,9 @@ void sortCommand(redisClient *c) { j++; } + /* Destructively convert encoded sorted sets for SORT. */ + if (sortval->type == REDIS_ZSET) zsetConvert(sortval, REDIS_ENCODING_SKIPLIST); + /* Load the sorting vector with all the objects to sort */ switch(sortval->type) { case REDIS_LIST: vectorlen = listTypeLength(sortval); break; @@ -363,12 +366,12 @@ void sortCommand(redisClient *c) { } } } - dbReplace(c->db,storekey,sobj); + setKey(c->db,storekey,sobj); + decrRefCount(sobj); /* Note: we add 1 because the DB is dirty anyway since even if the * SORT result is empty a new key is set and maybe the old content * replaced. */ server.dirty += 1+outputlen; - touchWatchedKey(c->db,storekey); addReplyLongLong(c,outputlen); }