summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2019-09-30 10:57:05 +0200
committerGitHub <noreply@github.com>2019-09-30 10:57:05 +0200
commitad45d7e407798d2996b5782470a64bd39b429be0 (patch)
tree29f598e0bbbd9944a2ea95d832e0a557d05f7dc3
parent916c4e5d864f55949e0202d2d9a073e19cf49b72 (diff)
parentaf15b285faa2a9cece8f5a76e05221836b6abae5 (diff)
downloadredis-ad45d7e407798d2996b5782470a64bd39b429be0.tar.gz
Merge pull request #6385 from filipecosta90/perf-reply-ss-error
Improve performance of RM_ReplyWithSimpleString and RM_ReplyWi…
-rw-r--r--src/module.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/module.c b/src/module.c
index 8e9ffbf87..9c2bed08f 100644
--- a/src/module.c
+++ b/src/module.c
@@ -1149,10 +1149,11 @@ int RM_ReplyWithLongLong(RedisModuleCtx *ctx, long long ll) {
int replyWithStatus(RedisModuleCtx *ctx, const char *msg, char *prefix) {
client *c = moduleGetReplyClient(ctx);
if (c == NULL) return REDISMODULE_OK;
- sds strmsg = sdsnewlen(prefix,1);
- strmsg = sdscat(strmsg,msg);
- strmsg = sdscatlen(strmsg,"\r\n",2);
- addReplySds(c,strmsg);
+ const size_t msgLen = strlen(msg);
+ const size_t prefixLen = strlen(prefix);
+ addReplyProto(c,prefix,prefixLen);
+ addReplyProto(c,msg,msgLen);
+ addReplyProto(c,"\r\n",2);
return REDISMODULE_OK;
}