From cc36f189f214cf0835483876d9ffa78f26f75dfe Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sun, 26 Feb 2017 18:12:37 +0100 Subject: [PATCH] Re #4502: Removed cache in Lua rotable search, tests have proven it does not speed up search significantly. Scripts that use some function a lot can use simple local variable to store pointer to the function - simpler and faster that cache. --- radio/src/thirdparty/Lua/src/lrotable.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/radio/src/thirdparty/Lua/src/lrotable.c b/radio/src/thirdparty/Lua/src/lrotable.c index 1322a7488..22f4d32a8 100644 --- a/radio/src/thirdparty/Lua/src/lrotable.c +++ b/radio/src/thirdparty/Lua/src/lrotable.c @@ -35,24 +35,6 @@ static luaR_result luaR_findkey(const void * where, const char * key, int type, } -char luaR_cachedName[LUA_MAX_ROTABLE_NAME + 1] = {0}; -TValue luaR_cachedValue; - -static inline void luaR_saveLastFoundGlobal(const char * name, const TValue * val) -{ - strcpy(luaR_cachedName, name); - luaR_cachedValue = *val; -} - -static inline luaR_result luaR_checkLastFoundGlobal(const char * name, TValue * val) -{ - if (!strcmp(luaR_cachedName, name)) { - *val = luaR_cachedValue; - return 1; - } - return 0; -} - /* Find a global "read only table" in the constant lua_rotable array */ luaR_result luaR_findglobal(const char * name, TValue * val) { unsigned i; @@ -60,21 +42,15 @@ luaR_result luaR_findglobal(const char * name, TValue * val) { TRACE_LUA_INTERNALS("luaR_findglobal('%s') = NAME TOO LONG", name); return 0; } - if (luaR_checkLastFoundGlobal(name, val)){ - TRACE_LUA_INTERNALS("luaR_findglobal('%s') = CACHED", name); - return 1; - } for (i=0; lua_rotable[i].name; i++) { void * table = (void *)(&lua_rotable[i]); if (!strcmp(lua_rotable[i].name, name)) { setrvalue(val, table); - luaR_saveLastFoundGlobal(name, val); TRACE_LUA_INTERNALS("luaR_findglobal('%s') = TABLE %p (%s)", name, table, lua_rotable[i].name); return 1; } if (!strncmp(lua_rotable[i].name, "__", 2)) { if (luaR_findentry(table, name, val)) { - // luaR_saveLastFoundGlobal(name, val); TRACE_LUA_INTERNALS("luaR_findglobal('%s') = FOUND in table '%s'", name, lua_rotable[i].name); return 1; }