Revert adding lua array per discussion in #222 (#229)

This reverts commit 55a15c204e.
This commit is contained in:
Paul Kulchenko 2021-08-07 15:20:33 -07:00 committed by GitHub
parent 6bbb44c165
commit 2bc0901ce3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 20 additions and 557 deletions

View file

@ -254,12 +254,9 @@ static int luaB_next (lua_State *L) {
}
}
static int luaB_ipairs (lua_State *L);
static int luaB_pairs (lua_State *L) {
luaL_checkany(L, 1);
if (lua_isarray(L, 1))
return luaB_ipairs(L);
if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */
lua_pushcfunction(L, luaB_next); /* will return generator, */
lua_pushvalue(L, 1); /* state, */
@ -282,16 +279,6 @@ static int ipairsaux (lua_State *L) {
return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2;
}
/*
** Traversal function for 'ipairs' specialized for arrays.
*/
static int ipairsauxarray (lua_State *L) {
lua_Integer i = luaL_checkinteger(L, 2) + 1;
lua_pushinteger(L, i);
lua_geti(L, 1, i);
return (lua_rawlen(L, 1) == i-1) ? 1 : 2;
}
/*
** 'ipairs' function. Returns 'ipairsaux', given "table", 0.
@ -299,7 +286,7 @@ static int ipairsauxarray (lua_State *L) {
*/
static int luaB_ipairs (lua_State *L) {
luaL_checkany(L, 1);
lua_pushcfunction(L, lua_isarray(L, 1) ? ipairsauxarray : ipairsaux); /* iteration function */
lua_pushcfunction(L, ipairsaux); /* iteration function */
lua_pushvalue(L, 1); /* state */
lua_pushinteger(L, 0); /* initial value */
return 3;