** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i */
| 552 | ** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i |
| 553 | */ |
| 554 | static void rehash (lua_State *L, Table *t, const TValue *ek) { |
| 555 | unsigned int asize; /* optimal size for array part */ |
| 556 | unsigned int na; /* number of keys in the array part */ |
| 557 | unsigned int nums[MAXABITS + 1]; |
| 558 | int i; |
| 559 | int totaluse; |
| 560 | for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */ |
| 561 | setlimittosize(t); |
| 562 | na = numusearray(t, nums); /* count keys in array part */ |
| 563 | totaluse = na; /* all those keys are integer keys */ |
| 564 | totaluse += numusehash(t, nums, &na); /* count keys in hash part */ |
| 565 | /* count extra key */ |
| 566 | if (ttisinteger(ek)) |
| 567 | na += countint(ivalue(ek), nums); |
| 568 | totaluse++; |
| 569 | /* compute new size for array part */ |
| 570 | asize = computesizes(nums, &na); |
| 571 | /* resize the table to new computed sizes */ |
| 572 | luaH_resize(L, t, asize, totaluse - na); |
| 573 | } |
| 574 | |
| 575 | |
| 576 |
no test coverage detected