MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / luaH_getn

Function luaH_getn

ThirdParty/lua/lua/ltable.c:622–638  ·  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

620** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
621*/
622int luaH_getn (Table *t) {
623 unsigned int j = t->sizearray;
624 if (j > 0 && ttisnil(&t->array[j - 1])) {
625 /* there is a boundary in the array part: (binary) search for it */
626 unsigned int i = 0;
627 while (j - i > 1) {
628 unsigned int m = (i+j)/2;
629 if (ttisnil(&t->array[m - 1])) j = m;
630 else i = m;
631 }
632 return i;
633 }
634 /* else must find a boundary in hash part */
635 else if (isdummy(t->node)) /* hash part is empty? */
636 return j; /* that is easy... */
637 else return unbound_search(t, j);
638}
639
640
641

Callers 2

luaV_objlenFunction · 0.85
lua_rawlenFunction · 0.85

Calls 1

unbound_searchFunction · 0.85

Tested by

no test coverage detected