MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaH_getn

Function luaH_getn

freebsd/contrib/openzfs/module/lua/ltable.c:563–579  ·  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

561** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
562*/
563int luaH_getn (Table *t) {
564 unsigned int j = t->sizearray;
565 if (j > 0 && ttisnil(&t->array[j - 1])) {
566 /* there is a boundary in the array part: (binary) search for it */
567 unsigned int i = 0;
568 while (j - i > 1) {
569 unsigned int m = (i+j)/2;
570 if (ttisnil(&t->array[m - 1])) j = m;
571 else i = m;
572 }
573 return i;
574 }
575 /* else must find a boundary in hash part */
576 else if (isdummy(t->node)) /* hash part is empty? */
577 return j; /* that is easy... */
578 else return unbound_search(t, j);
579}
580
581
582

Callers 2

luaV_objlenFunction · 0.70
lua_rawlenFunction · 0.70

Calls 1

unbound_searchFunction · 0.70

Tested by

no test coverage detected