@@ -24,9 +24,7 @@ use crate::types::{
2424 ReentrantMutexGuard , RegistryKey , VmState , XRc , XWeak ,
2525} ;
2626use crate :: userdata:: { AnyUserData , UserData , UserDataProxy , UserDataRegistry , UserDataStorage } ;
27- use crate :: util:: {
28- assert_stack, check_stack, protect_lua_closure, push_string, push_table, rawset_field, StackGuard ,
29- } ;
27+ use crate :: util:: { assert_stack, check_stack, protect_lua_closure, push_string, rawset_field, StackGuard } ;
3028use crate :: value:: { Nil , Value } ;
3129
3230#[ cfg( not( feature = "luau" ) ) ]
@@ -1202,28 +1200,7 @@ impl Lua {
12021200 K : IntoLua ,
12031201 V : IntoLua ,
12041202 {
1205- let lua = self . lock ( ) ;
1206- let state = lua. state ( ) ;
1207- unsafe {
1208- let _sg = StackGuard :: new ( state) ;
1209- check_stack ( state, 6 ) ?;
1210-
1211- let iter = iter. into_iter ( ) ;
1212- let lower_bound = iter. size_hint ( ) . 0 ;
1213- let protect = !lua. unlikely_memory_error ( ) ;
1214- push_table ( state, 0 , lower_bound, protect) ?;
1215- for ( k, v) in iter {
1216- lua. push ( k) ?;
1217- lua. push ( v) ?;
1218- if protect {
1219- protect_lua ! ( state, 3 , 1 , fn ( state) ffi:: lua_rawset( state, -3 ) ) ?;
1220- } else {
1221- ffi:: lua_rawset ( state, -3 ) ;
1222- }
1223- }
1224-
1225- Ok ( Table ( lua. pop_ref ( ) ) )
1226- }
1203+ unsafe { self . lock ( ) . create_table_from ( iter) }
12271204 }
12281205
12291206 /// Creates a table from an iterator of values, using `1..` as the keys.
0 commit comments