summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2022-06-07 17:59:22 +0100
committerAlex Orlenko <zxteam@protonmail.com>2022-06-07 17:59:22 +0100
commit4516ca0bb52635ed6a310fc2e9ce56a441d675c5 (patch)
treec372cde67293d48e1e9a205f152b3f3fe6b12199 /src
parent9005f32a984ed700dd87008bbd1452159203e7de (diff)
downloadmlua-4516ca0bb52635ed6a310fc2e9ce56a441d675c5.zip
Forgotten part of userdata performance optimization for Lua 5.1
Diffstat (limited to 'src')
-rw-r--r--src/lua.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lua.rs b/src/lua.rs
index fd8bab7..5efbe55 100644
--- a/src/lua.rs
+++ b/src/lua.rs
@@ -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()))
}