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

Function numusearray

third-party/lua-5.2.4/src/ltable.c:229–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228
229static int numusearray (const Table *t, int *nums) {
230 int lg;
231 int ttlg; /* 2^lg */
232 int ause = 0; /* summation of `nums' */
233 int i = 1; /* count to traverse all array keys */
234 for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) { /* for each slice */
235 int lc = 0; /* counter */
236 int lim = ttlg;
237 if (lim > t->sizearray) {
238 lim = t->sizearray; /* adjust upper limit */
239 if (i > lim)
240 break; /* no more elements to count */
241 }
242 /* count elements in range (2^(lg-1), 2^lg] */
243 for (; i <= lim; i++) {
244 if (!ttisnil(&t->array[i-1]))
245 lc++;
246 }
247 nums[lg] += lc;
248 ause += lc;
249 }
250 return ause;
251}
252
253
254static int numusehash (const Table *t, int *nums, int *pnasize) {

Callers 1

rehashFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected