diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-11-27 18:37:29 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-11-27 18:37:29 -0300 |
commit | 9329eeac3b7035c223d7a8b63dbde1f6db371bf5 (patch) | |
tree | d5f65b2f6a1521ea42fb011a5be59a4f2476b3da /ltable.c | |
parent | 682efe2678589eebc7c982e0ed66ad4990711e5a (diff) | |
download | lua-9329eeac3b7035c223d7a8b63dbde1f6db371bf5.tar.gz lua-9329eeac3b7035c223d7a8b63dbde1f6db371bf5.tar.bz2 lua-9329eeac3b7035c223d7a8b63dbde1f6db371bf5.zip |
Avoid an extra call to 'concretesize' in 'resizearray'
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -632,14 +632,14 @@ static Value *resizearray (lua_State *L , Table *t, | |||
632 | if (np == NULL) /* allocation error? */ | 632 | if (np == NULL) /* allocation error? */ |
633 | return NULL; | 633 | return NULL; |
634 | if (oldasize > 0) { | 634 | if (oldasize > 0) { |
635 | size_t oldasizeb = concretesize(oldasize); | ||
635 | /* move common elements to new position */ | 636 | /* move common elements to new position */ |
636 | Value *op = t->array - oldasize; /* real original array */ | 637 | Value *op = t->array - oldasize; /* real original array */ |
637 | unsigned tomove = (oldasize < newasize) ? oldasize : newasize; | 638 | unsigned tomove = (oldasize < newasize) ? oldasize : newasize; |
638 | lua_assert(tomove > 0); | 639 | size_t tomoveb = (oldasize < newasize) ? oldasizeb : newasizeb; |
639 | memcpy(np + newasize - tomove, | 640 | lua_assert(tomoveb > 0); |
640 | op + oldasize - tomove, | 641 | memcpy(np + newasize - tomove, op + oldasize - tomove, tomoveb); |
641 | concretesize(tomove)); | 642 | luaM_freemem(L, op, oldasizeb); |
642 | luaM_freemem(L, op, concretesize(oldasize)); | ||
643 | } | 643 | } |
644 | return np + newasize; /* shift pointer to the end of value segment */ | 644 | return np + newasize; /* shift pointer to the end of value segment */ |
645 | } | 645 | } |