aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-29 11:14:49 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-01-29 11:14:49 -0200
commitcaf01b5bfa33617b7bb2c40292f74599f6030eba (patch)
tree7ebc6352b89f9c331d693701aa4824a7320195e5 /ltable.c
parentca1f28b829090e99fb82d688dac34b2055d2963e (diff)
downloadlua-caf01b5bfa33617b7bb2c40292f74599f6030eba.tar.gz
lua-caf01b5bfa33617b7bb2c40292f74599f6030eba.tar.bz2
lua-caf01b5bfa33617b7bb2c40292f74599f6030eba.zip
better implementation for list "for"
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ltable.c b/ltable.c
index 5893f629..f8352fe5 100644
--- a/ltable.c
+++ b/ltable.c
@@ -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
75int 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
75static void setnodevector (lua_State *L, Hash *t, luint32 size) { 84static 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)