From c22aae461b69e1ea5f4cdc746ec577340f344baa Mon Sep 17 00:00:00 2001 From: kyren Date: Mon, 12 Feb 2018 13:42:13 -0500 Subject: Some changes for panic correctness, stack usage correctness, and speed --- src/lua.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/lua.rs') diff --git a/src/lua.rs b/src/lua.rs index 65d03d9..f0722f9 100644 --- a/src/lua.rs +++ b/src/lua.rs @@ -565,7 +565,7 @@ impl Lua { } stack_err_guard(self.state, 0, || { - check_stack(self.state, 1); + check_stack(self.state, 2); ffi::lua_rawgeti( self.state, ffi::LUA_REGISTRYINDEX, @@ -672,7 +672,7 @@ impl Lua { } } - // Uses 1 stack space, does not call checkstack + // Uses 2 stack spaces, does not call checkstack pub(crate) unsafe fn pop_value(&self, state: *mut ffi::lua_State) -> Value { match ffi::lua_type(state, -1) { ffi::LUA_TNIL => { @@ -709,10 +709,9 @@ impl Lua { ffi::LUA_TFUNCTION => Value::Function(Function(self.pop_ref(state))), ffi::LUA_TUSERDATA => { - // It should not be possible to interact with userdata types - // other than custom UserData types OR a WrappedError. - // WrappedPanic should never be able to be caught in lua, so it - // should never be here. + // It should not be possible to interact with userdata types other than custom + // UserData types OR a WrappedError. WrappedPanic should never be able to be caught + // in lua, so it should never be here. if let Some(err) = pop_wrapped_error(state) { Value::Error(err) } else { @@ -1011,7 +1010,7 @@ impl Lua { let nargs = ffi::lua_gettop(state); let mut args = MultiValue::new(); - check_stack(state, 1); + check_stack(state, 2); for _ in 0..nargs { args.push_front(lua.pop_value(state)); } -- cgit v1.2.3