From 3a86e1f2fde002199fff0ca4bb2ed4674b32ec8e Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Tue, 4 Jun 2024 09:21:15 +0200 Subject: Remove some useless compatibility stuff --- src/compat.h | 37 ------------------------------------- src/linda.cpp | 5 +---- src/tools.cpp | 10 ++++------ 3 files changed, 5 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/compat.h b/src/compat.h index fb31cab..7ac864e 100644 --- a/src/compat.h +++ b/src/compat.h @@ -61,7 +61,6 @@ inline char const* lua_typename(lua_State* L_, LuaType t_) // add some Lua 5.3-style API when building for Lua 5.1 #if LUA_VERSION_NUM == 501 -#define lua501_equal lua_equal inline int lua_absindex(lua_State* L_, int idx_) { return (((idx_) >= 0 || (idx_) <= LUA_REGISTRYINDEX) ? (idx_) : lua_gettop(L_) + (idx_) + 1); @@ -107,18 +106,6 @@ int luaL_getsubtable(lua_State* L_, int idx_, const char* fname_); // wrap Lua 5.2 calls under Lua 5.1 API when it is simpler that way #if LUA_VERSION_NUM == 502 -#ifndef lua501_equal // already defined when compatibility is active in luaconf.h -inline int lua501_equal(lua_State* L_, int a_, int b_) -{ - return lua_compare(L_, a_, b_, LUA_OPEQ); -} -#endif // lua501_equal -#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h -inline int lua_lessthan(lua_State* L_, int a_, int b_) -{ - return lua_compare(L_, a_, b_, LUA_OPLT); -} -#endif // lua_lessthan inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[]) { luaL_setfuncs(L_, funcs_, 0); @@ -149,18 +136,6 @@ inline int lua504_dump(lua_State* L_, lua_Writer writer_, void* data_, [[maybe_u // wrap Lua 5.3 calls under Lua 5.1 API when it is simpler that way #if LUA_VERSION_NUM == 503 -#ifndef lua501_equal // already defined when compatibility is active in luaconf.h -inline int lua501_equal(lua_State* L_, int a_, int b_) -{ - return lua_compare(L_, a_, b_, LUA_OPEQ); -} -#endif // lua501_equal -#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h -inline int lua_lessthan(lua_State* L_, int a_, int b_) -{ - return lua_compare(L_, a_, b_, LUA_OPLT); -} -#endif // lua_lessthan inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[]) { luaL_setfuncs(L_, funcs_, 0); @@ -193,18 +168,6 @@ int lua_setiuservalue(lua_State* L_, int idx_, int n_); // wrap Lua 5.4 calls under Lua 5.1 API when it is simpler that way #if LUA_VERSION_NUM == 504 -#ifndef lua501_equal // already defined when compatibility is active in luaconf.h -inline int lua501_equal(lua_State* L_, int a_, int b_) -{ - return lua_compare(L_, a_, b_, LUA_OPEQ); -} -#endif // lua501_equal -#ifndef lua_lessthan // already defined when compatibility is active in luaconf.h -inline int lua_lessthan(lua_State* L_, int a_, int b_) -{ - return lua_compare(L_, a_, b_, LUA_OPLT); -} -#endif // lua_lessthan inline void luaG_registerlibfuncs(lua_State* L_, luaL_Reg const funcs_[]) { luaL_setfuncs(L_, funcs_, 0); diff --git a/src/linda.cpp b/src/linda.cpp index 2a31799..f1a99fd 100644 --- a/src/linda.cpp +++ b/src/linda.cpp @@ -461,10 +461,7 @@ LUAG_FUNC(linda_receive) keeper_api_t _selected_keeper_receive{ nullptr }; int _expected_pushed_min{ 0 }, _expected_pushed_max{ 0 }; // are we in batched mode? - kLindaBatched.pushKey(L_); - int const _is_batched{ lua501_equal(L_, _key_i, -1) }; - lua_pop(L_, 1); - if (_is_batched) { + if (kLindaBatched.equals(L_, -1)) { // no need to pass linda.batched in the keeper state ++_key_i; // make sure the keys are of a valid type diff --git a/src/tools.cpp b/src/tools.cpp index 94e941d..e6dadd2 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -151,14 +151,12 @@ static void update_lookup_entry(lua_State* L_, int ctxBase_, int depth_) std::string_view const _newName{ tools::PushFQN(L_, _fqn, depth_) }; // L_: ... {bfc} k o name? "f.q.n" // Lua 5.2 introduced a hash randomizer seed which causes table iteration to yield a different key order // on different VMs even when the tables are populated the exact same way. - // When Lua is built with compatibility options (such as LUA_COMPAT_ALL), - // this causes several base libraries to register functions under multiple names. - // This, with the randomizer, can cause the first generated name of an object to be different on different VMs, - // which breaks function transfer. + // Also, when Lua is built with compatibility options (such as LUA_COMPAT_ALL), some base libraries register functions under multiple names. + // This, with the randomizer, can cause the first generated name of an object to be different on different VMs, which breaks function transfer. // Also, nothing prevents any external module from exposing a given object under several names, so... - // Therefore, when we encounter an object for which a name was previously registered, we need to select the names + // Therefore, when we encounter an object for which a name was previously registered, we need to select the a single name // based on some sorting order so that we end up with the same name in all databases whatever order the table walk yielded - if (!_prevName.empty() && (_prevName.size() < _newName.size() || lua_lessthan(L_, -2, -1))) { + if (!_prevName.empty() && ((_prevName.size() < _newName.size()) || (_prevName <= _newName))) { DEBUGSPEW_CODE(DebugSpew(_U) << lua_typename(L_, lua_type(L_, -3)) << " '" << _newName << "' remains named '" << _prevName << "'" << std::endl); // the previous name is 'smaller' than the one we just generated: keep it! lua_pop(L_, 3); // L_: ... {bfc} k -- cgit v1.2.3-55-g6feb