From 739893075675af06b1cc5d782a984e3624e98ff9 Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 12 Aug 2013 12:43:26 +0200 Subject: [PATCH] Use precomptued objects for bulk and mbulk prefixes. --- src/networking.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/networking.c b/src/networking.c index d128646f1..be78a19f2 100644 --- a/src/networking.c +++ b/src/networking.c @@ -474,7 +474,10 @@ void addReplyLongLong(redisClient *c, long long ll) { } void addReplyMultiBulkLen(redisClient *c, long length) { - addReplyLongLongWithPrefix(c,length,'*'); + if (length < REDIS_SHARED_BULKHDR_LEN) + addReply(c,shared.mbulkhdr[length]); + else + addReplyLongLongWithPrefix(c,length,'*'); } /* Create the length prefix of a bulk reply, example: $2234 */ @@ -496,7 +499,11 @@ void addReplyBulkLen(redisClient *c, robj *obj) { len++; } } - addReplyLongLongWithPrefix(c,len,'$'); + + if (len < REDIS_SHARED_BULKHDR_LEN) + addReply(c,shared.bulkhdr[len]); + else + addReplyLongLongWithPrefix(c,len,'$'); } /* Add a Redis Object as a bulk reply */ -- GitLab