From 562b403a66a6a96d883620b27455564d50e3d49b Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Wed, 9 Jan 2013 11:47:16 +0100 Subject: Micro-optimizations for pushing strings to Lua Use lua_pushliteral and lua_pushlstring instead of lua_pushstring, which avoids Lua having to determine the length of the string. --- src/scripting/luautil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/scripting/luautil.cpp') diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp index 3de23c7..f7b39e2 100644 --- a/src/scripting/luautil.cpp +++ b/src/scripting/luautil.cpp @@ -86,8 +86,8 @@ void UserDataCache::insert(lua_State *s, void *object) // The metatable that makes the values in the table above weak lua_newtable(s); // UD, Cache, {} - lua_pushstring(s, "__mode"); - lua_pushstring(s, "v"); + lua_pushliteral(s, "__mode"); + lua_pushliteral(s, "v"); lua_rawset(s, -3); // UD, Cache, { __mode = "v" } lua_setmetatable(s, -2); // UD, Cache -- cgit