From 9329eeac3b7035c223d7a8b63dbde1f6db371bf5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 27 Nov 2024 18:37:29 -0300 Subject: Avoid an extra call to 'concretesize' in 'resizearray' --- ltable.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ltable.c') diff --git a/ltable.c b/ltable.c index 21fafa5e..71a6f30d 100644 --- a/ltable.c +++ b/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 */ } -- cgit v1.2.3-55-g6feb