File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ use super::{Lua, WeakLua};
2828static EXTRA_REGISTRY_KEY : u8 = 0 ;
2929
3030const WRAPPED_FAILURE_POOL_DEFAULT_CAPACITY : usize = 64 ;
31- const REF_STACK_RESERVE : c_int = 1 ;
31+ const REF_STACK_RESERVE : c_int = 2 ;
3232
3333/// Data associated with the Lua state.
3434pub ( crate ) struct ExtraData {
Original file line number Diff line number Diff line change @@ -468,26 +468,16 @@ impl Table {
468468 ///
469469 /// It checks both the array part and the hash part.
470470 pub fn is_empty ( & self ) -> bool {
471- // Check array part
472- if self . raw_len ( ) != 0 {
473- return false ;
474- }
475-
476- // Check hash part
477471 let lua = self . 0 . lua . lock ( ) ;
478- let state = lua. state ( ) ;
472+ let ref_thread = lua. ref_thread ( ) ;
479473 unsafe {
480- let _sg = StackGuard :: new ( state) ;
481- assert_stack ( state, 4 ) ;
482-
483- lua. push_ref ( & self . 0 ) ;
484- ffi:: lua_pushnil ( state) ;
485- if ffi:: lua_next ( state, -2 ) != 0 {
486- return false ;
474+ ffi:: lua_pushnil ( ref_thread) ;
475+ if ffi:: lua_next ( ref_thread, self . 0 . index ) == 0 {
476+ return true ;
487477 }
478+ ffi:: lua_pop ( ref_thread, 2 ) ;
488479 }
489-
490- true
480+ false
491481 }
492482
493483 /// Returns a reference to the metatable of this table, or `None` if no metatable is set.
You can’t perform that action at this time.
0 commit comments