summaryrefslogtreecommitdiff
path: root/lvm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-03 11:54:58 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-07-03 11:54:58 -0300
commitae809e9fd132ab867741a6a777450f9bc0d49be4 (patch)
tree402821af72bbf8ee5a5779b48ba978cb6f578416 /lvm.c
parente96385adede47a1abf160a41565ec742d3d4e413 (diff)
downloadlua-github-ae809e9fd132ab867741a6a777450f9bc0d49be4.tar.gz
'luaV_concat' can "concat" one single value
Several of its callers needed that case and had to do the check themselves.
Diffstat (limited to 'lvm.c')
-rw-r--r--lvm.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lvm.c b/lvm.c
index e7781dbf..ccbfbab5 100644
--- a/lvm.c
+++ b/lvm.c
@@ -634,7 +634,8 @@ static void copy2buff (StkId top, int n, char *buff) {
** from 'L->top - total' up to 'L->top - 1'.
*/
void luaV_concat (lua_State *L, int total) {
- lua_assert(total >= 2);
+ if (total == 1)
+ return; /* "all" values already concatenated */
do {
StkId top = L->top;
int n = 2; /* number of elements handled in this pass (at least 2) */
@@ -840,10 +841,8 @@ void luaV_finishOp (lua_State *L) {
int a = GETARG_A(inst); /* first element to concatenate */
int total = cast_int(top - 1 - (base + a)); /* yet to concatenate */
setobjs2s(L, top - 2, top); /* put TM result in proper position */
- if (total > 1) { /* are there elements to concat? */
- L->top = top - 1; /* top is one after last element (at top-2) */
- luaV_concat(L, total); /* concat them (may yield again) */
- }
+ L->top = top - 1; /* top is one after last element (at top-2) */
+ luaV_concat(L, total); /* concat them (may yield again) */
break;
}
default: {