Simplify Table::clear method

There is no need to traverse array part, lua_next will cover everything
This commit is contained in:
Alex Orlenko
2025-09-08 23:09:26 +01:00
parent 40b507c3ec
commit bad20374ad
+1 -8
View File
@@ -416,14 +416,7 @@ impl Table {
lua.push_ref(&self.0);
// Clear array part
for i in 1..=ffi::lua_rawlen(state, -1) {
ffi::lua_pushnil(state);
ffi::lua_rawseti(state, -2, i as Integer);
}
// Clear hash part
// It must be safe as long as we don't use invalid keys
// This is safe as long as we don't assign new keys
ffi::lua_pushnil(state);
while ffi::lua_next(state, -2) != 0 {
ffi::lua_pop(state, 1); // pop value