summaryrefslogtreecommitdiffstats
path: root/src/scripting/luautil.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-01-09 11:47:16 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-01-09 11:47:16 +0100
commit562b403a66a6a96d883620b27455564d50e3d49b (patch)
tree44b3f37bef0b44999dce6a1a941f6ff94baaa0e5 /src/scripting/luautil.cpp
parent2594084de6e163f15a1516d64cf413de5b0d899f (diff)
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.
Diffstat (limited to 'src/scripting/luautil.cpp')
-rw-r--r--src/scripting/luautil.cpp4
1 files changed, 2 insertions, 2 deletions
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