** Try to find a boundary in table `t'. A `boundary' is an integer index ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). */
| 9798 | ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). |
| 9799 | */ |
| 9800 | int luaH_getn (Table *t) { |
| 9801 | unsigned int j = t->sizearray; |
| 9802 | if (j > 0 && ttisnil(&t->array[j - 1])) { |
| 9803 | /* there is a boundary in the array part: (binary) search for it */ |
| 9804 | unsigned int i = 0; |
| 9805 | while (j - i > 1) { |
| 9806 | unsigned int m = (i+j)/2; |
| 9807 | if (ttisnil(&t->array[m - 1])) j = m; |
| 9808 | else i = m; |
| 9809 | } |
| 9810 | return i; |
| 9811 | } |
| 9812 | /* else must find a boundary in hash part */ |
| 9813 | else if (t->node == dummynode) /* hash part is empty? */ |
| 9814 | return j; /* that is easy... */ |
| 9815 | else return unbound_search(t, j); |
| 9816 | } |
| 9817 | |
| 9818 | |
| 9819 |
no test coverage detected