diff options
Diffstat (limited to 'src/ffi/lua51/compat.rs')
-rw-r--r-- | src/ffi/lua51/compat.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ffi/lua51/compat.rs b/src/ffi/lua51/compat.rs index 892c507..9cd46fb 100644 --- a/src/ffi/lua51/compat.rs +++ b/src/ffi/lua51/compat.rs @@ -155,6 +155,13 @@ pub unsafe fn lua_absindex(L: *mut lua_State, mut idx: c_int) -> c_int { pub unsafe fn lua_rotate(L: *mut lua_State, mut idx: c_int, mut n: c_int) { idx = lua_absindex(L, idx); + if n > 0 { + // Faster version + for _ in 0..n { + lua_insert(L, idx); + } + return; + } let n_elems = lua_gettop(L) - idx + 1; if n < 0 { n += n_elems; |