diff options
author | antirez <antirez@gmail.com> | 2014-05-05 17:07:09 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2014-05-07 16:17:11 +0200 |
commit | 67e350367d68ba3bc0cf05092190eb6607844dc8 (patch) | |
tree | 8655561f19c5935a76529f02bd1a29d2b90d3412 | |
parent | b06de30dd78746263bc49fe91c97277f7766d820 (diff) | |
download | redis-67e350367d68ba3bc0cf05092190eb6607844dc8.tar.gz |
Scripting: simpler reply buffer creation in luaRedisGenericCommand().
It if faster to just create the string with a single sdsnewlen() call.
If c->bufpos is zero, the call will simply be like sdsemtpy().
-rw-r--r-- | src/scripting.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/scripting.c b/src/scripting.c index 5fe0b60a3..5b8f49097 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -306,11 +306,8 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { /* Convert the result of the Redis command into a suitable Lua type. * The first thing we need is to create a single string from the client * output buffers. */ - reply = sdsempty(); - if (c->bufpos) { - reply = sdscatlen(reply,c->buf,c->bufpos); - c->bufpos = 0; - } + reply = sdsnewlen(c->buf,c->bufpos); + c->bufpos = 0; while(listLength(c->reply)) { robj *o = listNodeValue(listFirst(c->reply)); |