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

Function luaH_getn

src/Chain/libraries/glua/ltable.cpp:775–791  ·  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

773** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
774*/
775int luaH_getn(Table *t) {
776 unsigned int j = t->sizearray;
777 if (j > 0 && ttisnil(&t->array[j - 1])) {
778 /* there is a boundary in the array part: (binary) search for it */
779 unsigned int i = 0;
780 while (j - i > 1) {
781 unsigned int m = (i + j) / 2;
782 if (ttisnil(&t->array[m - 1])) j = m;
783 else i = m;
784 }
785 return i;
786 }
787 /* else must find a boundary in hash part */
788 else if (isdummy(t->node)) /* hash part is empty? */
789 return j; /* that is easy... */
790 else return unbound_search(t, j);
791}
792
793
794

Callers 2

luaV_objlenFunction · 0.85
lua_rawlenFunction · 0.85

Calls 1

unbound_searchFunction · 0.85

Tested by

no test coverage detected