MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / numusearray

Function numusearray

Source/Misc/lua/src/lua.c:9462–9484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9460
9461
9462static int numusearray (const Table *t, int *nums) {
9463int lg;
9464int ttlg; /* 2^lg */
9465int ause = 0; /* summation of `nums' */
9466int i = 1; /* count to traverse all array keys */
9467for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
9468int lc = 0; /* counter */
9469int lim = ttlg;
9470if (lim > t->sizearray) {
9471lim = t->sizearray; /* adjust upper limit */
9472if (i > lim)
9473break; /* no more elements to count */
9474}
9475/* count elements in range (2^(lg-1), 2^lg] */
9476for (; i <= lim; i++) {
9477if (!ttisnil(&t->array[i-1]))
9478lc++;
9479}
9480nums[lg] += lc;
9481ause += lc;
9482}
9483return ause;
9484}
9485
9486
9487static int numusehash (const Table *t, int *nums, int *pnasize) {

Callers 1

rehashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected