diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-29 11:14:49 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-29 11:14:49 -0200 |
commit | caf01b5bfa33617b7bb2c40292f74599f6030eba (patch) | |
tree | 7ebc6352b89f9c331d693701aa4824a7320195e5 /ltable.c | |
parent | ca1f28b829090e99fb82d688dac34b2055d2963e (diff) | |
download | lua-caf01b5bfa33617b7bb2c40292f74599f6030eba.tar.gz lua-caf01b5bfa33617b7bb2c40292f74599f6030eba.tar.bz2 lua-caf01b5bfa33617b7bb2c40292f74599f6030eba.zip |
better implementation for list "for"
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.69 2001/01/26 14:16:35 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.70 2001/01/26 15:58:50 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -72,6 +72,15 @@ Node *luaH_next (lua_State *L, Hash *t, const TObject *key) { | |||
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | int luaH_nexti (Hash *t, int i) { | ||
76 | for (i++; i<t->size; i++) { | ||
77 | if (ttype(val(node(t, i))) != LUA_TNIL) /* a non-nil value? */ | ||
78 | return i; | ||
79 | } | ||
80 | return -1; /* no more elements */ | ||
81 | } | ||
82 | |||
83 | |||
75 | static void setnodevector (lua_State *L, Hash *t, luint32 size) { | 84 | static void setnodevector (lua_State *L, Hash *t, luint32 size) { |
76 | int i; | 85 | int i; |
77 | if (size > MAX_INT) | 86 | if (size > MAX_INT) |