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.
This commit is contained in:
antirez 2014-05-06 15:04:02 +02:00
parent 76fda9f8e1
commit 1e4ba6e7e6

View File

@ -226,9 +226,12 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
} }
for (j = 0; j < argc; j++) { for (j = 0; j < argc; j++) {
if (!lua_isstring(lua,j+1)) break; char *obj_s;
argv[j] = createStringObject((char*)lua_tostring(lua,j+1), size_t obj_len;
lua_strlen(lua,j+1));
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 /* Check if one of the arguments passed by the Lua script