MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaH_next

Function luaH_next

depends/lua/src/ltable.c:186–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185
186int luaH_next (lua_State *L, Table *t, StkId key) {
187 unsigned int i = findindex(L, t, key); /* find original element */
188 for (; i < t->sizearray; i++) { /* try first array part */
189 if (!ttisnil(&t->array[i])) { /* a non-nil value? */
190 setivalue(key, i + 1);
191 setobj2s(L, key+1, &t->array[i]);
192 return 1;
193 }
194 }
195 for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) { /* hash part */
196 if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
197 setobj2s(L, key, gkey(gnode(t, i)));
198 setobj2s(L, key+1, gval(gnode(t, i)));
199 return 1;
200 }
201 }
202 return 0; /* no more elements */
203}
204
205
206/*

Callers 1

lua_nextFunction · 0.85

Calls 1

findindexFunction · 0.85

Tested by

no test coverage detected