diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-04-01 10:51:37 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-04-01 10:51:37 -0300 |
commit | 409ee99900216d4a64a9a7029099bc7ae67a4d8e (patch) | |
tree | 87e222896d5bee4ca9b07becfd64fe6e76c53cf9 /ltable.c | |
parent | 445eda7ead2e9800e3928acfd902f61968aaca11 (diff) | |
download | lua-409ee99900216d4a64a9a7029099bc7ae67a4d8e.tar.gz lua-409ee99900216d4a64a9a7029099bc7ae67a4d8e.tar.bz2 lua-409ee99900216d4a64a9a7029099bc7ae67a4d8e.zip |
detail
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.18 2005/03/09 16:28:07 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.19 2005/03/16 16:58:41 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 | */ |
@@ -557,9 +557,8 @@ int luaH_getn (Table *t) { | |||
557 | unsigned int j = t->sizearray; | 557 | unsigned int j = t->sizearray; |
558 | if (j > 0 && ttisnil(&t->array[j - 1])) { | 558 | if (j > 0 && ttisnil(&t->array[j - 1])) { |
559 | /* there is a boundary in the array part: (binary) search for it */ | 559 | /* there is a boundary in the array part: (binary) search for it */ |
560 | unsigned int i = 1; | 560 | unsigned int i = 0; |
561 | if (ttisnil(&t->array[1 - 1])) return 0; | 561 | while (j - i > 1) { |
562 | while (i < j - 1) { | ||
563 | unsigned int m = (i+j)/2; | 562 | unsigned int m = (i+j)/2; |
564 | if (ttisnil(&t->array[m - 1])) j = m; | 563 | if (ttisnil(&t->array[m - 1])) j = m; |
565 | else i = m; | 564 | else i = m; |