From ae809e9fd132ab867741a6a777450f9bc0d49be4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 3 Jul 2020 11:54:58 -0300 Subject: 'luaV_concat' can "concat" one single value Several of its callers needed that case and had to do the check themselves. --- lapi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index 184b8dd7..bbba88a3 100644 --- a/lapi.c +++ b/lapi.c @@ -1239,14 +1239,12 @@ LUA_API void lua_toclose (lua_State *L, int idx) { LUA_API void lua_concat (lua_State *L, int n) { lua_lock(L); api_checknelems(L, n); - if (n >= 2) { + if (n > 0) luaV_concat(L, n); - } - else if (n == 0) { /* push empty string */ - setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); + else { /* nothing to concatenate */ + setsvalue2s(L, L->top, luaS_newlstr(L, "", 0)); /* push empty string */ api_incr_top(L); } - /* else n == 1; nothing to do */ luaC_checkGC(L); lua_unlock(L); } -- cgit v1.2.3-55-g6feb