mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
better implementation for list "for"
This commit is contained in:
parent
ca1f28b829
commit
caf01b5bfa
5 changed files with 39 additions and 20 deletions
11
ltable.c
11
ltable.c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ltable.c,v 1.69 2001/01/26 14:16:35 roberto Exp roberto $
|
||||
** $Id: ltable.c,v 1.70 2001/01/26 15:58:50 roberto Exp roberto $
|
||||
** Lua tables (hash)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
|
@ -72,6 +72,15 @@ Node *luaH_next (lua_State *L, Hash *t, const TObject *key) {
|
|||
}
|
||||
|
||||
|
||||
int luaH_nexti (Hash *t, int i) {
|
||||
for (i++; i<t->size; i++) {
|
||||
if (ttype(val(node(t, i))) != LUA_TNIL) /* a non-nil value? */
|
||||
return i;
|
||||
}
|
||||
return -1; /* no more elements */
|
||||
}
|
||||
|
||||
|
||||
static void setnodevector (lua_State *L, Hash *t, luint32 size) {
|
||||
int i;
|
||||
if (size > MAX_INT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue