MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / numusearray

Function numusearray

lua/ltable.c:256–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254
255
256static int numusearray (const Table *t, int *nums) {
257 int lg;
258 int ttlg; /* 2^lg */
259 int ause = 0; /* summation of `nums' */
260 int i = 1; /* count to traverse all array keys */
261 for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
262 int lc = 0; /* counter */
263 int lim = ttlg;
264 if (lim > t->sizearray) {
265 lim = t->sizearray; /* adjust upper limit */
266 if (i > lim)
267 break; /* no more elements to count */
268 }
269 /* count elements in range (2^(lg-1), 2^lg] */
270 for (; i <= lim; i++) {
271 if (!ttisnil(&t->array[i-1]))
272 lc++;
273 }
274 nums[lg] += lc;
275 ause += lc;
276 }
277 return ause;
278}
279
280
281static int numusehash (const Table *t, int *nums, int *pnasize) {

Callers 1

rehashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected