MCPcopy Create free account
hub / github.com/Tencent/xLua / luaH_getn

Function luaH_getn

WebGLPlugins/ltable.c:641–657  ·  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

639** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
640*/
641int luaH_getn (Table *t) {
642 unsigned int j = t->sizearray;
643 if (j > 0 && ttisnil(&t->array[j - 1])) {
644 /* there is a boundary in the array part: (binary) search for it */
645 unsigned int i = 0;
646 while (j - i > 1) {
647 unsigned int m = (i+j)/2;
648 if (ttisnil(&t->array[m - 1])) j = m;
649 else i = m;
650 }
651 return i;
652 }
653 /* else must find a boundary in hash part */
654 else if (isdummy(t)) /* hash part is empty? */
655 return j; /* that is easy... */
656 else return unbound_search(t, j);
657}
658
659
660

Callers 2

luaV_objlenFunction · 0.85
lua_rawlenFunction · 0.85

Calls 1

unbound_searchFunction · 0.85

Tested by

no test coverage detected