| 8992 | |
| 8993 | namespace stack { |
| 8994 | inline void remove(lua_State* L, int rawindex, int count) { |
| 8995 | if (count < 1) |
| 8996 | return; |
| 8997 | int top = lua_gettop(L); |
| 8998 | if (top < 1) { |
| 8999 | return; |
| 9000 | } |
| 9001 | if (rawindex == -count || top == rawindex) { |
| 9002 | // Slice them right off the top |
| 9003 | lua_pop(L, static_cast<int>(count)); |
| 9004 | return; |
| 9005 | } |
| 9006 | |
| 9007 | // Remove each item one at a time using stack operations |
| 9008 | // Probably slower, maybe, haven't benchmarked, |
| 9009 | // but necessary |
| 9010 | int index = lua_absindex(L, rawindex); |
| 9011 | if (index < 0) { |
| 9012 | index = lua_gettop(L) + (index + 1); |
| 9013 | } |
| 9014 | int last = index + count; |
| 9015 | for (int i = index; i < last; ++i) { |
| 9016 | lua_remove(L, index); |
| 9017 | } |
| 9018 | } |
| 9019 | |
| 9020 | struct push_popper_at { |
| 9021 | lua_State* L; |
no test coverage detected