addReplyLongLong optimized to return shared objects when the value to reply is 0 or 1

This commit is contained in:
antirez 2011-04-15 18:08:24 +02:00
parent 2e667806ed
commit 009db67645

View File

@ -321,7 +321,12 @@ void _addReplyLongLong(redisClient *c, long long ll, char prefix) {
}
void addReplyLongLong(redisClient *c, long long ll) {
_addReplyLongLong(c,ll,':');
if (ll == 0)
addReply(c,shared.czero);
else if (ll == 1)
addReply(c,shared.cone);
else
_addReplyLongLong(c,ll,':');
}
void addReplyMultiBulkLen(redisClient *c, long length) {