** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i */
| 510 | ** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i |
| 511 | */ |
| 512 | static void rehash(lua_State *L, Table *t, const TValue *ek) { |
| 513 | unsigned int asize; /* optimal size for array part */ |
| 514 | unsigned int na; /* number of keys in the array part */ |
| 515 | unsigned int nums[MAXABITS + 1]; |
| 516 | int i; |
| 517 | int totaluse; |
| 518 | for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */ |
| 519 | na = numusearray(t, nums); /* count keys in array part */ |
| 520 | totaluse = na; /* all those keys are integer keys */ |
| 521 | totaluse += numusehash(t, nums, &na); /* count keys in hash part */ |
| 522 | /* count extra key */ |
| 523 | na += countint(ek, nums); |
| 524 | totaluse++; |
| 525 | /* compute new size for array part */ |
| 526 | asize = computesizes(nums, &na); |
| 527 | /* resize the table to new computed sizes */ |
| 528 | luaH_resize(L, t, asize, totaluse - na); |
| 529 | } |
| 530 | |
| 531 | |
| 532 |
no test coverage detected