diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index b3ad954e..f0ba01c1 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2016-08-17 20:02:13.087012 UTC -// This header was generated with sol v2.11.4 (revision 5ac32c7) +// Generated 2016-08-19 03:51:21.744027 UTC +// This header was generated with sol v2.11.4 (revision c8ea9f7) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -4844,17 +4844,35 @@ namespace sol { T arr; index = lua_absindex(L, index); - lua_pushnil(L); - while (lua_next(L, index) != 0) { - int isint = 0; - lua_tointegerx(L, -2, &isint); - if (isint == 0) { - lua_pop(L, 1); - continue; +#if SOL_LUA_VERSION >= 503 + // This method is HIGHLY performant over regular table iteration thanks to the Lua API changes in 5.3 + for (lua_Integer i = 0; ; ++i, lua_pop(L, 1)) { + type t = static_cast(lua_geti(L, index, i)); + if (t == type::nil) { + if (i == 0) + continue; + else + break; } arr.push_back(stack::get(L, -1)); - lua_pop(L, 1); } + lua_pop(L, 1); +#else + // Zzzz slower but necessary thanks to the lower version API and missing functions qq + for (lua_Integer i = 0; ; ++i, lua_pop(L, 1)) { + lua_pushinteger(L, i); + lua_gettable(L, index); + type t = type_of(L, -1); + if (t == type::nil) { + if (i == 0) + continue; + else + break; + } + arr.push_back(stack::get(L, -1)); + } + lua_pop(L, 1); +#endif return arr; } }; diff --git a/sol/stack_get.hpp b/sol/stack_get.hpp index c7669f24..fa34b810 100644 --- a/sol/stack_get.hpp +++ b/sol/stack_get.hpp @@ -85,17 +85,35 @@ namespace sol { T arr; index = lua_absindex(L, index); - lua_pushnil(L); - while (lua_next(L, index) != 0) { - int isint = 0; - lua_tointegerx(L, -2, &isint); - if (isint == 0) { - lua_pop(L, 1); - continue; +#if SOL_LUA_VERSION >= 503 + // This method is HIGHLY performant over regular table iteration thanks to the Lua API changes in 5.3 + for (lua_Integer i = 0; ; ++i, lua_pop(L, 1)) { + type t = static_cast(lua_geti(L, index, i)); + if (t == type::nil) { + if (i == 0) + continue; + else + break; } arr.push_back(stack::get(L, -1)); - lua_pop(L, 1); } + lua_pop(L, 1); +#else + // Zzzz slower but necessary thanks to the lower version API and missing functions qq + for (lua_Integer i = 0; ; ++i, lua_pop(L, 1)) { + lua_pushinteger(L, i); + lua_gettable(L, index); + type t = type_of(L, -1); + if (t == type::nil) { + if (i == 0) + continue; + else + break; + } + arr.push_back(stack::get(L, -1)); + } + lua_pop(L, 1); +#endif return arr; } };