MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / rehash

Function rehash

3rd/lua-5.4.3/src/ltable.c:587–606  ·  view source on GitHub ↗

** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i */

Source from the content-addressed store, hash-verified

585** nums[i] = number of keys 'k' where 2^(i - 1) < k <= 2^i
586*/
587static 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

Callers 2

luaH_newkeyFunction · 0.85
insertMethod · 0.85

Calls 6

setlimittosizeFunction · 0.85
numusearrayFunction · 0.85
numusehashFunction · 0.85
countintFunction · 0.85
computesizesFunction · 0.85
luaH_resizeFunction · 0.85

Tested by

no test coverage detected