diff options
-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; |