diff options
| author | Alexander Gavrilov | 2012-04-01 18:34:04 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-04-01 18:34:04 +0400 |
| commit | e3d50b9b042165b352ffd041395844fd57d36db8 (patch) | |
| tree | 7be6f786bb5d587608ca6abd3146a4d057660112 /library/LuaTypes.cpp | |
| parent | 604c84953b21093c69e34c8c9b3851aa34fbc7ff (diff) | |
| download | dfhack-e3d50b9b042165b352ffd041395844fd57d36db8.tar.gz dfhack-e3d50b9b042165b352ffd041395844fd57d36db8.tar.bz2 dfhack-e3d50b9b042165b352ffd041395844fd57d36db8.tar.xz | |
Optimize wrapper: use pointers instead of strings as most frequent keys.
Diffstat (limited to 'library/LuaTypes.cpp')
| -rw-r--r-- | library/LuaTypes.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/LuaTypes.cpp b/library/LuaTypes.cpp index 550dc239..6d5961f8 100644 --- a/library/LuaTypes.cpp +++ b/library/LuaTypes.cpp @@ -1032,7 +1032,7 @@ static int meta_call_function(lua_State *state) static void AddMethodWrapper(lua_State *state, int meta_idx, int field_idx, const char *name, function_identity_base *fun) { - lua_getfield(state, LUA_REGISTRYINDEX, DFHACK_TYPETABLE_NAME); + lua_rawgetp(state, LUA_REGISTRYINDEX, &DFHACK_TYPETABLE_TOKEN); lua_pushvalue(state, meta_idx); lua_pushfstring(state, "%s()", name); lua_pushlightuserdata(state, fun); @@ -1331,7 +1331,7 @@ void LuaWrapper::push_adhoc_pointer(lua_State *state, void *ptr, type_identity * return; } - LookupInTable(state, target, DFHACK_PTR_IDTABLE_NAME); + LookupInTable(state, target, &DFHACK_PTR_IDTABLE_TOKEN); type_identity *id = (type_identity*)lua_touserdata(state, -1); lua_pop(state, 1); @@ -1347,7 +1347,7 @@ void LuaWrapper::push_adhoc_pointer(lua_State *state, void *ptr, type_identity * void *newobj = lua_newuserdata(state, sizeof(pointer_identity)); id = new (newobj) pointer_identity(target); - SaveInTable(state, target, DFHACK_PTR_IDTABLE_NAME); + SaveInTable(state, target, &DFHACK_PTR_IDTABLE_TOKEN); lua_pop(state, 1); } |
