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

Function numusearray

src/Chain/libraries/glua/ltable.cpp:393–416  ·  view source on GitHub ↗

** Count keys in array part of table 't': Fill 'nums[i]' with ** number of keys that will go into corresponding slice and return ** total number of non-nil keys. */

Source from the content-addressed store, hash-verified

391** total number of non-nil keys.
392*/
393static unsigned int numusearray(const Table *t, unsigned int *nums) {
394 int lg;
395 unsigned int ttlg; /* 2^lg */
396 unsigned int ause = 0; /* summation of 'nums' */
397 unsigned int i = 1; /* count to traverse all array keys */
398 /* traverse each slice */
399 for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) {
400 unsigned int lc = 0; /* counter */
401 unsigned int lim = ttlg;
402 if (lim > t->sizearray) {
403 lim = t->sizearray; /* adjust upper limit */
404 if (i > lim)
405 break; /* no more elements to count */
406 }
407 /* count elements in range (2^(lg - 1), 2^lg] */
408 for (; i <= lim; i++) {
409 if (!ttisnil(&t->array[i - 1]))
410 lc++;
411 }
412 nums[lg] += lc;
413 ause += lc;
414 }
415 return ause;
416}
417
418
419static int numusehash(const Table *t, unsigned int *nums, unsigned int *pna) {

Callers 1

rehashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected