| 8420 | |
| 8421 | namespace stack { |
| 8422 | inline void remove(lua_State* L, int rawindex, int count) { |
| 8423 | if (count < 1) |
| 8424 | return; |
| 8425 | int top = lua_gettop(L); |
| 8426 | if (top < 1) { |
| 8427 | return; |
| 8428 | } |
| 8429 | if (rawindex == -count || top == rawindex) { |
| 8430 | // Slice them right off the top |
| 8431 | lua_pop(L, static_cast<int>(count)); |
| 8432 | return; |
| 8433 | } |
| 8434 | |
| 8435 | // Remove each item one at a time using stack operations |
| 8436 | // Probably slower, maybe, haven't benchmarked, |
| 8437 | // but necessary |
| 8438 | int index = lua_absindex(L, rawindex); |
| 8439 | if (index < 0) { |
| 8440 | index = lua_gettop(L) + (index + 1); |
| 8441 | } |
| 8442 | int last = index + count; |
| 8443 | for (int i = index; i < last; ++i) { |
| 8444 | lua_remove(L, index); |
| 8445 | } |
| 8446 | } |
| 8447 | |
| 8448 | struct push_popper_at { |
| 8449 | lua_State* L; |
no test coverage detected