MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / tremove

Function tremove

deps/lua/src/ltablib.c:118–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116
117
118static int tremove (lua_State *L) {
119 int e = aux_getn(L, 1);
120 int pos = luaL_optint(L, 2, e);
121 if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
122 return 0; /* nothing to remove */
123 luaL_setn(L, 1, e - 1); /* t.n = n-1 */
124 lua_rawgeti(L, 1, pos); /* result = t[pos] */
125 for ( ;pos<e; pos++) {
126 lua_rawgeti(L, 1, pos+1);
127 lua_rawseti(L, 1, pos); /* t[pos] = t[pos+1] */
128 }
129 lua_pushnil(L);
130 lua_rawseti(L, 1, e); /* t[e] = nil */
131 return 1;
132}
133
134
135static void addfield (lua_State *L, luaL_Buffer *b, int i) {

Callers

nothing calls this directly

Calls 4

luaL_setnFunction · 0.85
lua_rawgetiFunction · 0.85
lua_rawsetiFunction · 0.85
lua_pushnilFunction · 0.85

Tested by

no test coverage detected