MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / luaH_getn

Function luaH_getn

other_src/lua/src/ltable.cpp:597–613  ·  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

595** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
596*/
597int luaH_getn (Table *t) {
598 unsigned int j = t->sizearray;
599 if (j > 0 && ttisnil(&t->array[j - 1])) {
600 /* there is a boundary in the array part: (binary) search for it */
601 unsigned int i = 0;
602 while (j - i > 1) {
603 unsigned int m = (i+j)/2;
604 if (ttisnil(&t->array[m - 1])) j = m;
605 else i = m;
606 }
607 return i;
608 }
609 /* else must find a boundary in hash part */
610 else if (t->node == dummynode) /* hash part is empty? */
611 return j; /* that is easy... */
612 else return unbound_search(t, j);
613}
614
615
616

Callers 2

luaV_executeFunction · 0.70
lua_objlenFunction · 0.70

Calls 1

unbound_searchFunction · 0.70

Tested by

no test coverage detected