mirror of
https://github.com/lua/lua
synced 2025-02-24 09:04:02 +03:00
Avoid an extra call to 'concretesize' in 'resizearray'
This commit is contained in:
parent
682efe2678
commit
9329eeac3b
10
ltable.c
10
ltable.c
@ -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 */
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user