MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaH_getn

Function luaH_getn

Source/Misc/lua/src/lua.c:9800–9816  ·  view source on GitHub ↗

** 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). */

Source from the content-addressed store, hash-verified

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

Callers 2

lua_objlenFunction · 0.85
luaV_executeFunction · 0.85

Calls 1

unbound_searchFunction · 0.85

Tested by

no test coverage detected