MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / numusearray

Function numusearray

third-party/lua-5.5.0/src/ltable.c:488–513  ·  view source on GitHub ↗

** Count keys in array part of table 't'. */

Source from the content-addressed store, hash-verified

486** Count keys in array part of table 't'.
487*/
488static void numusearray (const Table *t, Counters *ct) {
489 int lg;
490 unsigned int ttlg; /* 2^lg */
491 unsigned int ause = 0; /* summation of 'nums' */
492 unsigned int i = 1; /* index to traverse all array keys */
493 unsigned int asize = t->asize;
494 /* traverse each slice */
495 for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) {
496 unsigned int lc = 0; /* counter */
497 unsigned int lim = ttlg;
498 if (lim > asize) {
499 lim = asize; /* adjust upper limit */
500 if (i > lim)
501 break; /* no more elements to count */
502 }
503 /* count elements in range (2^(lg - 1), 2^lg] */
504 for (; i <= lim; i++) {
505 if (!arraykeyisempty(t, i))
506 lc++;
507 }
508 ct->nums[lg] += lc;
509 ause += lc;
510 }
511 ct->total += ause;
512 ct->na += ause;
513}
514
515
516/*

Callers 1

rehashFunction · 0.70

Calls 1

arraykeyisemptyFunction · 0.85

Tested by

no test coverage detected