** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i */
| 393 | ** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i |
| 394 | */ |
| 395 | static void rehash (lua_State *L, Table *t, const TValue *ek) { |
| 396 | unsigned int asize; /* optimal size for array part */ |
| 397 | unsigned int na; /* number of keys in the array part */ |
| 398 | unsigned int nums[MAXABITS + 1]; |
| 399 | int i; |
| 400 | int totaluse; |
| 401 | for (i = 0; i <= MAXABITS; i++) nums[i] = 0; /* reset counts */ |
| 402 | na = numusearray(t, nums); /* count keys in array part */ |
| 403 | totaluse = na; /* all those keys are integer keys */ |
| 404 | totaluse += numusehash(t, nums, &na); /* count keys in hash part */ |
| 405 | /* count extra key */ |
| 406 | na += countint(ek, nums); |
| 407 | totaluse++; |
| 408 | /* compute new size for array part */ |
| 409 | asize = computesizes(nums, &na); |
| 410 | /* resize the table to new computed sizes */ |
| 411 | luaH_resize(L, t, asize, totaluse - na); |
| 412 | } |
| 413 | |
| 414 | |
| 415 |
no test coverage detected