From 432b0c07f9f906b30863660f02cf66cabecf0ecd Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 13 Oct 2021 23:02:40 +0800 Subject: [PATCH] array may hash part only --- lualib-src/lua-bson.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lualib-src/lua-bson.c b/lualib-src/lua-bson.c index 8c62c5e8..e77a0612 100644 --- a/lualib-src/lua-bson.c +++ b/lualib-src/lua-bson.c @@ -512,7 +512,6 @@ pack_meta_dict(lua_State *L, struct bson *b, int depth) { static bool is_rawarray(lua_State *L) { - // test first key, hash part first in Lua 5.4 lua_pushnil(L); if (lua_next(L, -2) == 0) { // empty table @@ -520,17 +519,7 @@ is_rawarray(lua_State *L) { } lua_Integer firstkey = lua_isinteger(L, -2) ? lua_tointeger(L, -2) : 0; lua_pop(L, 2); - if (firstkey != 1) - return false; - - size_t len = lua_rawlen(L, -1); - lua_pushinteger(L, len); - if (lua_next(L,-2) == 0) { - return true; - } else { - lua_pop(L,2); - return false; - } + return firstkey > 0; } static void