diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2022-06-07 17:59:22 +0100 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2022-06-07 17:59:22 +0100 |
commit | 4516ca0bb52635ed6a310fc2e9ce56a441d675c5 (patch) | |
tree | c372cde67293d48e1e9a205f152b3f3fe6b12199 /src | |
parent | 9005f32a984ed700dd87008bbd1452159203e7de (diff) | |
download | mlua-4516ca0bb52635ed6a310fc2e9ce56a441d675c5.zip |
Forgotten part of userdata performance optimization for Lua 5.1
Diffstat (limited to 'src')
-rw-r--r-- | src/lua.rs | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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())) } |