** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i */
| 596 | ** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i |
| 597 | */ |
| 598 | static void rehash (lua_State *L, Table *t, const TValue *ek) { |
| 599 | unsigned int asize; /* optimal size for array part */ |
| 600 | unsigned int na; /* number of keys in the array part */ |
| 601 | unsigned int nums[MAXABITS + 1]; |
| 602 | int i; |
| 603 | int totaluse; |
| 604 | for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */ |
| 605 | setlimittosize(t); |
| 606 | na = numusearray(t, nums); /* count keys in array part */ |
| 607 | totaluse = na; /* all those keys are integer keys */ |
| 608 | totaluse += numusehash(t, nums, &na); /* count keys in hash part */ |
| 609 | /* count extra key */ |
| 610 | if (ttisinteger(ek)) |
| 611 | na += countint(ivalue(ek), nums); |
| 612 | totaluse++; |
| 613 | /* compute new size for array part */ |
| 614 | asize = computesizes(nums, &na); |
| 615 | /* resize the table to new computed sizes */ |
| 616 | luaH_resize(L, t, asize, totaluse - na); |
| 617 | } |
| 618 | |
| 619 | |
| 620 |
no test coverage detected