MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / resize

Function resize

Source/Misc/lua/src/lua.c:9537–9564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9535
9536
9537static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
9538int i;
9539int oldasize = t->sizearray;
9540int oldhsize = t->lsizenode;
9541Node *nold = t->node; /* save old hash ... */
9542if (nasize > oldasize) /* array part must grow? */
9543setarrayvector(L, t, nasize);
9544/* create new hash part with appropriate size */
9545setnodevector(L, t, nhsize);
9546if (nasize < oldasize) { /* array part must shrink? */
9547t->sizearray = nasize;
9548/* re-insert elements from vanishing slice */
9549for (i=nasize; i<oldasize; i++) {
9550if (!ttisnil(&t->array[i]))
9551setobjt2t(L, luaH_setnum(L, t, i+1), &t->array[i]);
9552}
9553/* shrink array */
9554luaM_reallocvector(L, t->array, oldasize, nasize, TValue);
9555}
9556/* re-insert elements from hash part */
9557for (i = twoto(oldhsize) - 1; i >= 0; i--) {
9558Node *old = nold+i;
9559if (!ttisnil(gval(old)))
9560setobjt2t(L, luaH_set(L, t, key2tval(old)), gval(old));
9561}
9562if (nold != dummynode)
9563luaM_freearray(L, nold, twoto(oldhsize), Node); /* free old array */
9564}
9565
9566
9567void luaH_resizearray (lua_State *L, Table *t, int nasize) {

Callers 13

luaH_resizearrayFunction · 0.85
rehashFunction · 0.85
~StringMethod · 0.85
setChar8Method · 0.85
setChar16Method · 0.85
fstring.cppFile · 0.85
trimMethod · 0.85
removeCharsMethod · 0.85
removeChars8Method · 0.85
removeChars16Method · 0.85
takeMethod · 0.85
fromCFStringRefMethod · 0.85

Calls 4

setarrayvectorFunction · 0.85
setnodevectorFunction · 0.85
luaH_setnumFunction · 0.85
luaH_setFunction · 0.85

Tested by

no test coverage detected