This commit is contained in:
Cloud Wu
2021-10-13 12:57:55 +08:00
parent 0ae839b2dd
commit f80e2cd9b1

View File

@@ -512,16 +512,25 @@ pack_meta_dict(lua_State *L, struct bson *b, int depth) {
static bool static bool
is_rawarray(lua_State *L) { is_rawarray(lua_State *L) {
size_t len = lua_rawlen(L, -1); // test first key, hash part first in Lua 5.4
if (len > 0) { lua_pushnil(L);
lua_pushinteger(L, len); if (lua_next(L, -2) == 0) {
if (lua_next(L,-2) == 0) { // empty table
return true; return false;
} else { }
lua_pop(L,2); lua_Integer firstkey = lua_tointeger(L, -2);
} 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 false;
} }
static void static void