From b70d355521fd02737c4de2a1583025699f1554f8 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 2 Sep 2010 14:30:56 +0200 Subject: [PATCH] Use existing reply functions where possible --- src/db.c | 6 ++---- src/sort.c | 2 +- src/t_hash.c | 2 +- src/t_list.c | 6 +++--- src/t_set.c | 2 +- src/t_string.c | 2 +- src/t_zset.c | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/db.c b/src/db.c index 8c6c6bc8..4d119cf2 100644 --- a/src/db.c +++ b/src/db.c @@ -245,13 +245,11 @@ void keysCommand(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) { - addReplySds(c, - sdscatprintf(sdsempty(),":%lu\r\n",server.lastsave)); + addReplyLongLong(c,server.lastsave); } void typeCommand(redisClient *c) { diff --git a/src/sort.c b/src/sort.c index f53ad486..79f79010 100644 --- a/src/sort.c +++ b/src/sort.c @@ -369,7 +369,7 @@ void sortCommand(redisClient *c) { * replaced. */ server.dirty += 1+outputlen; touchWatchedKey(c->db,storekey); - addReplySds(c,sdscatprintf(sdsempty(),":%d\r\n",outputlen)); + addReplyLongLong(c,outputlen); } /* Cleanup */ diff --git a/src/t_hash.c b/src/t_hash.c index ad5d3e1e..5745f88c 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -346,7 +346,7 @@ void hlenCommand(redisClient *c) { 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) { diff --git a/src/t_list.c b/src/t_list.c index db9ca18e..4d948294 100644 --- a/src/t_list.c +++ b/src/t_list.c @@ -342,7 +342,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) { server.dirty++; } - addReplyUlong(c,listTypeLength(subject)); + addReplyLongLong(c,listTypeLength(subject)); } 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; - addReplyUlong(c,listTypeLength(o)); + addReplyLongLong(c,listTypeLength(o)); } void lindexCommand(redisClient *c) { @@ -594,7 +594,7 @@ void lremCommand(redisClient *c) { 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]); } diff --git a/src/t_set.c b/src/t_set.c index 17cac934..e2ac5ae5 100644 --- a/src/t_set.c +++ b/src/t_set.c @@ -276,7 +276,7 @@ void scardCommand(redisClient *c) { 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) { diff --git a/src/t_string.c b/src/t_string.c index 411687a5..276f4dab 100644 --- a/src/t_string.c +++ b/src/t_string.c @@ -211,7 +211,7 @@ void appendCommand(redisClient *c) { } 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) { diff --git a/src/t_zset.c b/src/t_zset.c index 7de63158..6a332c6a 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -930,7 +930,7 @@ void zcardCommand(redisClient *c) { checkType(c,o,REDIS_ZSET)) return; zs = o->ptr; - addReplyUlong(c,zs->zsl->length); + addReplyLongLong(c,zs->zsl->length); } void zscoreCommand(redisClient *c) { -- 2.45.2