summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-05-06 15:04:02 +0200
committerantirez <antirez@gmail.com>2014-05-07 16:17:11 +0200
commit87516f1a4da59fc5aa499d56aa61a3808b127ed7 (patch)
tree71290263340ae524b36e0ef15b80afc743a0fce9
parent1b5524f697c17ba6ec663fa01d51570584e9efdf (diff)
downloadredis-87516f1a4da59fc5aa499d56aa61a3808b127ed7.tar.gz
Scripting: Use faster API for Lua client c->argv creation.
Replace the three calls to Lua API lua_tostring, lua_lua_strlen, and lua_isstring, with a single call to lua_tolstring. ~ 5% consistent speed gain measured.
-rw-r--r--src/scripting.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/scripting.c b/src/scripting.c
index 9d4c8e75c..941ce76b7 100644
--- a/src/scripting.c
+++ b/src/scripting.c
@@ -226,9 +226,12 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
}
for (j = 0; j < argc; j++) {
- if (!lua_isstring(lua,j+1)) break;
- argv[j] = createStringObject((char*)lua_tostring(lua,j+1),
- lua_strlen(lua,j+1));
+ char *obj_s;
+ size_t obj_len;
+
+ obj_s = (char*)lua_tolstring(lua,j+1,&obj_len);
+ if (obj_s == NULL) break; /* Not a string. */
+ argv[j] = createStringObject(obj_s, obj_len);
}
/* Check if one of the arguments passed by the Lua script