MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / luaH_next

Function luaH_next

lua/ltable.c:196–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194
195
196int luaH_next (lua_State *L, Table *t, StkId key) {
197 int i = findindex(L, t, key); /* find original element */
198 for (i++; i < t->sizearray; i++) { /* try first array part */
199 if (!ttisnil(&t->array[i])) { /* a non-nil value? */
200 setnvalue(key, cast_num(i+1));
201 setobj2s(L, key+1, &t->array[i]);
202 return 1;
203 }
204 }
205 for (i -= t->sizearray; i < sizenode(t); i++) { /* then hash part */
206 if (!ttisnil(gval(gnode(t, i)))) { /* a non-nil value? */
207 setobj2s(L, key, key2tval(gnode(t, i)));
208 setobj2s(L, key+1, gval(gnode(t, i)));
209 return 1;
210 }
211 }
212 return 0; /* no more elements */
213}
214
215
216/*

Callers 1

lua_nextFunction · 0.85

Calls 1

findindexFunction · 0.85

Tested by

no test coverage detected