Forgotten part of userdata performance optimization for Lua 5.1

This commit is contained in:
Alex Orlenko 2022-06-07 17:59:22 +01:00
parent 9005f32a98
commit 4516ca0bb5
No known key found for this signature in database
GPG key ID: 4C150C250863B96D

View file

@ -2822,10 +2822,15 @@ impl Lua {
// Set empty environment for Lua 5.1
#[cfg(any(feature = "lua51", feature = "luajit"))]
protect_lua!(self.state, 1, 1, fn(state) {
ffi::lua_newtable(state);
ffi::lua_setuservalue(state, -2);
})?;
if protect {
protect_lua!(self.state, 1, 1, fn(state) {
ffi::lua_newtable(state);
ffi::lua_setuservalue(state, -2);
})?;
} else {
ffi::lua_newtable(self.state);
ffi::lua_setuservalue(self.state, -2);
}
Ok(AnyUserData(self.pop_ref()))
}