Avoid an extra call to 'concretesize' in 'resizearray'
This commit is contained in:
10
ltable.c
10
ltable.c
@@ -632,14 +632,14 @@ static Value *resizearray (lua_State *L , Table *t,
|
|||||||
if (np == NULL) /* allocation error? */
|
if (np == NULL) /* allocation error? */
|
||||||
return NULL;
|
return NULL;
|
||||||
if (oldasize > 0) {
|
if (oldasize > 0) {
|
||||||
|
size_t oldasizeb = concretesize(oldasize);
|
||||||
/* move common elements to new position */
|
/* move common elements to new position */
|
||||||
Value *op = t->array - oldasize; /* real original array */
|
Value *op = t->array - oldasize; /* real original array */
|
||||||
unsigned tomove = (oldasize < newasize) ? oldasize : newasize;
|
unsigned tomove = (oldasize < newasize) ? oldasize : newasize;
|
||||||
lua_assert(tomove > 0);
|
size_t tomoveb = (oldasize < newasize) ? oldasizeb : newasizeb;
|
||||||
memcpy(np + newasize - tomove,
|
lua_assert(tomoveb > 0);
|
||||||
op + oldasize - tomove,
|
memcpy(np + newasize - tomove, op + oldasize - tomove, tomoveb);
|
||||||
concretesize(tomove));
|
luaM_freemem(L, op, oldasizeb);
|
||||||
luaM_freemem(L, op, concretesize(oldasize));
|
|
||||||
}
|
}
|
||||||
return np + newasize; /* shift pointer to the end of value segment */
|
return np + newasize; /* shift pointer to the end of value segment */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user