Skip to content

Commit

Permalink
Avoid an extra call to 'concretesize' in 'resizearray'
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-ieru committed Nov 27, 2024
1 parent 682efe2 commit 9329eea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ltable.c
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,14 @@ static Value *resizearray (lua_State *L , Table *t,
if (np == NULL) /* allocation error? */
return NULL;
if (oldasize > 0) {
size_t oldasizeb = concretesize(oldasize);
/* move common elements to new position */
Value *op = t->array - oldasize; /* real original array */
unsigned tomove = (oldasize < newasize) ? oldasize : newasize;
lua_assert(tomove > 0);
memcpy(np + newasize - tomove,
op + oldasize - tomove,
concretesize(tomove));
luaM_freemem(L, op, concretesize(oldasize));
size_t tomoveb = (oldasize < newasize) ? oldasizeb : newasizeb;
lua_assert(tomoveb > 0);
memcpy(np + newasize - tomove, op + oldasize - tomove, tomoveb);
luaM_freemem(L, op, oldasizeb);
}
return np + newasize; /* shift pointer to the end of value segment */
}
Expand Down

0 comments on commit 9329eea

Please sign in to comment.