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