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

Function computesizes

Source/Misc/lua/src/lua.c:9429–9448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9427
9428
9429static int computesizes (int nums[], int *narray) {
9430int i;
9431int twotoi; /* 2^i */
9432int a = 0; /* number of elements smaller than 2^i */
9433int na = 0; /* number of elements to go to array part */
9434int n = 0; /* optimal size for array part */
9435for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
9436if (nums[i] > 0) {
9437a += nums[i];
9438if (a > twotoi/2) { /* more than half elements present? */
9439n = twotoi; /* optimal size (till now) */
9440na = a; /* all elements smaller than n will go to array part */
9441}
9442}
9443if (a == *narray) break; /* all elements already counted */
9444}
9445*narray = n;
9446lua_assert(*narray/2 <= na && na <= *narray);
9447return na;
9448}
9449
9450
9451static int countint (const TValue *key, int *nums) {

Callers 1

rehashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected