summaryrefslogtreecommitdiff
path: root/src/lvm.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-14 01:00:28 +0000
committerdaurnimator <quae@daurnimator.com>2017-05-14 01:01:24 +0000
commit8c5f476397c6943d5c49e37ca26118b908d67143 (patch)
tree25c371978d0f9f4e60a23a34e8124700767f076d /src/lvm.js
parent5e6003fa9d84b2207a70743ead9086f7cbfdf9d6 (diff)
downloadfengari-8c5f476397c6943d5c49e37ca26118b908d67143.tar.gz
fengari-8c5f476397c6943d5c49e37ca26118b908d67143.tar.bz2
fengari-8c5f476397c6943d5c49e37ca26118b908d67143.zip
Partially revert 4cccf8c6b2c2b1af0afafef52bc87477ba7f817a
Diffstat (limited to 'src/lvm.js')
-rw-r--r--src/lvm.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lvm.js b/src/lvm.js
index 6a1602c..d48610c 100644
--- a/src/lvm.js
+++ b/src/lvm.js
@@ -971,13 +971,18 @@ const luaV_concat = function(L, total) {
delete L.stack[top - 1];
} else {
/* at least two non-empty string values; get as many as possible */
- let concatenated = L.stack[top-1].svalue();
+ let toconcat = new Array(total);
+ toconcat[total-1] = L.stack[top-1].svalue();
delete L.stack[top - 1];
- for (n = 1; n < total && tostring(L, top - n - 1); n++) {
- concatenated = L.stack[top - n - 1].svalue().concat(concatenated);
+ for (n = 1; n < total; n++) {
+ if (!tostring(L, top - n - 1)) {
+ toconcat = toconcat.slice(total-n);
+ break;
+ }
+ toconcat[total-n-1] = L.stack[top - n - 1].svalue();
delete L.stack[top - n - 1];
}
- let ts = lstring.luaS_bless(L, concatenated);
+ let ts = lstring.luaS_bless(L, Array.prototype.concat.apply([], toconcat));
L.stack[top - n] = new lobject.TValue(CT.LUA_TLNGSTR, ts);
}
total -= n - 1; /* got 'n' strings to create 1 new */