]> git.saurik.com Git - redis.git/commitdiff
Use existing reply functions where possible
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Thu, 2 Sep 2010 12:30:56 +0000 (14:30 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Thu, 2 Sep 2010 17:52:04 +0000 (19:52 +0200)
src/db.c
src/sort.c
src/t_hash.c
src/t_list.c
src/t_set.c
src/t_string.c
src/t_zset.c

index 8c6c6bc82d4c2cb2610e692875651e6a59fa7fe7..4d119cf299ea05adb165b2ae918ae6d0e7dcf305 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -245,13 +245,11 @@ void keysCommand(redisClient *c) {
 }
 
 void dbsizeCommand(redisClient *c) {
 }
 
 void dbsizeCommand(redisClient *c) {
-    addReplySds(c,
-        sdscatprintf(sdsempty(),":%lu\r\n",dictSize(c->db->dict)));
+    addReplyLongLong(c,dictSize(c->db->dict));
 }
 
 void lastsaveCommand(redisClient *c) {
 }
 
 void lastsaveCommand(redisClient *c) {
-    addReplySds(c,
-        sdscatprintf(sdsempty(),":%lu\r\n",server.lastsave));
+    addReplyLongLong(c,server.lastsave);
 }
 
 void typeCommand(redisClient *c) {
 }
 
 void typeCommand(redisClient *c) {
index f53ad4865b0cffb6b52705fecdf544e849b414ee..79f7901054c0971e6c52addfbb126bd53afb1854 100644 (file)
@@ -369,7 +369,7 @@ void sortCommand(redisClient *c) {
          * replaced. */
         server.dirty += 1+outputlen;
         touchWatchedKey(c->db,storekey);
          * replaced. */
         server.dirty += 1+outputlen;
         touchWatchedKey(c->db,storekey);
-        addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",outputlen));
+        addReplyLongLong(c,outputlen);
     }
 
     /* Cleanup */
     }
 
     /* Cleanup */
index ad5d3e1e80b0182dd1a00b3588f448e42f3c21e4..5745f88c39b9fd135812521dc72324c9485139b1 100644 (file)
@@ -346,7 +346,7 @@ void hlenCommand(redisClient *c) {
     if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
         checkType(c,o,REDIS_HASH)) return;
 
     if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
         checkType(c,o,REDIS_HASH)) return;
 
-    addReplyUlong(c,hashTypeLength(o));
+    addReplyLongLong(c,hashTypeLength(o));
 }
 
 void genericHgetallCommand(redisClient *c, int flags) {
 }
 
 void genericHgetallCommand(redisClient *c, int flags) {
index db9ca18e9c615b59880e84cc2a302aae364d0427..4d948294e7bd57020dee70789a11d441d9ccf274 100644 (file)
@@ -342,7 +342,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
         server.dirty++;
     }
 
         server.dirty++;
     }
 
-    addReplyUlong(c,listTypeLength(subject));
+    addReplyLongLong(c,listTypeLength(subject));
 }
 
 void lpushxCommand(redisClient *c) {
 }
 
 void lpushxCommand(redisClient *c) {
@@ -366,7 +366,7 @@ void linsertCommand(redisClient *c) {
 void llenCommand(redisClient *c) {
     robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.czero);
     if (o == NULL || checkType(c,o,REDIS_LIST)) return;
 void llenCommand(redisClient *c) {
     robj *o = lookupKeyReadOrReply(c,c->argv[1],shared.czero);
     if (o == NULL || checkType(c,o,REDIS_LIST)) return;
-    addReplyUlong(c,listTypeLength(o));
+    addReplyLongLong(c,listTypeLength(o));
 }
 
 void lindexCommand(redisClient *c) {
 }
 
 void lindexCommand(redisClient *c) {
@@ -594,7 +594,7 @@ void lremCommand(redisClient *c) {
         decrRefCount(obj);
 
     if (listTypeLength(subject) == 0) dbDelete(c->db,c->argv[1]);
         decrRefCount(obj);
 
     if (listTypeLength(subject) == 0) dbDelete(c->db,c->argv[1]);
-    addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",removed));
+    addReplyLongLong(c,removed);
     if (removed) touchWatchedKey(c->db,c->argv[1]);
 }
 
     if (removed) touchWatchedKey(c->db,c->argv[1]);
 }
 
index 17cac934c75258fa6831f1dd14d980db0825438f..e2ac5ae5378155f329f76d90d7f5c6680e959f05 100644 (file)
@@ -276,7 +276,7 @@ void scardCommand(redisClient *c) {
     if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
         checkType(c,o,REDIS_SET)) return;
 
     if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
         checkType(c,o,REDIS_SET)) return;
 
-    addReplyUlong(c,setTypeSize(o));
+    addReplyLongLong(c,setTypeSize(o));
 }
 
 void spopCommand(redisClient *c) {
 }
 
 void spopCommand(redisClient *c) {
index 411687a5e219e31d1b593ee1d365b4a2f90d52f5..276f4daba28bed08e2a083ea8944263be8a6ffc7 100644 (file)
@@ -211,7 +211,7 @@ void appendCommand(redisClient *c) {
     }
     touchWatchedKey(c->db,c->argv[1]);
     server.dirty++;
     }
     touchWatchedKey(c->db,c->argv[1]);
     server.dirty++;
-    addReplySds(c,sdscatprintf(sdsempty(),":%lu\r\n",(unsigned long)totlen));
+    addReplyLongLong(c,totlen);
 }
 
 void substrCommand(redisClient *c) {
 }
 
 void substrCommand(redisClient *c) {
index 7de63158d573e3590d99bcf645547b61dcc720c9..6a332c6ae90180e031c0218bc5653874cc8bddd5 100644 (file)
@@ -930,7 +930,7 @@ void zcardCommand(redisClient *c) {
         checkType(c,o,REDIS_ZSET)) return;
 
     zs = o->ptr;
         checkType(c,o,REDIS_ZSET)) return;
 
     zs = o->ptr;
-    addReplyUlong(c,zs->zsl->length);
+    addReplyLongLong(c,zs->zsl->length);
 }
 
 void zscoreCommand(redisClient *c) {
 }
 
 void zscoreCommand(redisClient *c) {