@@ -173,7 +173,7 @@ pub struct LuaOptions {
173173
174174 /// Max size of thread (coroutine) object pool used to execute asynchronous functions.
175175 ///
176- /// It works on Lua 5.4, LuaJIT (vendored) and Luau, where [`lua_resetthread`] function
176+ /// It works on Lua 5.4 and Luau, where [`lua_resetthread`] function
177177 /// is available and allows to reuse old coroutines after resetting their state.
178178 ///
179179 /// Default: **0** (disabled)
@@ -377,22 +377,14 @@ impl Lua {
377377
378378 /// Creates a new Lua state with required `libs` and `options`
379379 unsafe fn inner_new ( libs : StdLib , options : LuaOptions ) -> Lua {
380- // Skip Rust allocator for non-vendored LuaJIT (see https://github.com/khvzak/mlua/issues/176)
381- let use_rust_allocator = !( cfg ! ( feature = "luajit" ) && cfg ! ( not( feature = "vendored" ) ) ) ;
382-
383- let ( state, mem_state) = if use_rust_allocator {
384- let mut mem_state: * mut MemoryState = Box :: into_raw ( Box :: default ( ) ) ;
385- let mut state = ffi:: lua_newstate ( ALLOCATOR , mem_state as * mut c_void ) ;
386- // If state is null (it's possible for LuaJIT on non-x86 arch) then switch to Lua internal allocator
387- if state. is_null ( ) {
388- drop ( Box :: from_raw ( mem_state) ) ;
389- mem_state = ptr:: null_mut ( ) ;
390- state = ffi:: luaL_newstate ( ) ;
391- }
392- ( state, mem_state)
393- } else {
394- ( ffi:: luaL_newstate ( ) , ptr:: null_mut ( ) )
395- } ;
380+ let mut mem_state: * mut MemoryState = Box :: into_raw ( Box :: default ( ) ) ;
381+ let mut state = ffi:: lua_newstate ( ALLOCATOR , mem_state as * mut c_void ) ;
382+ // If state is null then switch to Lua internal allocator
383+ if state. is_null ( ) {
384+ drop ( Box :: from_raw ( mem_state) ) ;
385+ mem_state = ptr:: null_mut ( ) ;
386+ state = ffi:: luaL_newstate ( ) ;
387+ }
396388 assert ! ( !state. is_null( ) , "Failed to instantiate Lua VM" ) ;
397389
398390 ffi:: luaL_requiref ( state, cstr ! ( "_G" ) , ffi:: luaopen_base, 1 ) ;
@@ -1673,11 +1665,7 @@ impl Lua {
16731665 & ' lua self ,
16741666 func : & Function ,
16751667 ) -> Result < Thread < ' lua > > {
1676- #[ cfg( any(
1677- feature = "lua54" ,
1678- all( feature = "luajit" , feature = "vendored" ) ,
1679- feature = "luau" ,
1680- ) ) ]
1668+ #[ cfg( any( feature = "lua54" , feature = "luau" ) ) ]
16811669 unsafe {
16821670 let state = self . state ( ) ;
16831671 let _sg = StackGuard :: new ( state) ;
@@ -1703,11 +1691,7 @@ impl Lua {
17031691
17041692 /// Resets thread (coroutine) and returns to the pool for later use.
17051693 #[ cfg( feature = "async" ) ]
1706- #[ cfg( any(
1707- feature = "lua54" ,
1708- all( feature = "luajit" , feature = "vendored" ) ,
1709- feature = "luau" ,
1710- ) ) ]
1694+ #[ cfg( any( feature = "lua54" , feature = "luau" ) ) ]
17111695 pub ( crate ) unsafe fn recycle_thread ( & self , thread : & mut Thread ) -> bool {
17121696 let extra = & mut * self . extra . get ( ) ;
17131697 if extra. thread_pool . len ( ) < extra. thread_pool . capacity ( ) {
@@ -1721,8 +1705,6 @@ impl Lua {
17211705 // Error object is on top, drop it
17221706 ffi:: lua_settop ( thread_state, 0 ) ;
17231707 }
1724- #[ cfg( all( feature = "luajit" , feature = "vendored" ) ) ]
1725- ffi:: lua_resetthread ( self . state ( ) , thread_state) ;
17261708 #[ cfg( feature = "luau" ) ]
17271709 ffi:: lua_resetthread ( thread_state) ;
17281710 extra. thread_pool . push ( thread. 0 . index ) ;
0 commit comments