better implementation for list "for"

This commit is contained in:
Roberto Ierusalimschy
2001-01-29 11:14:49 -02:00
parent ca1f28b829
commit caf01b5bfa
5 changed files with 39 additions and 20 deletions

View File

@@ -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)