aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-11 15:45:34 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-11 15:53:09 +1100
commit5b564fb8e230f98b672aea534c16d7d99ffe1944 (patch)
tree2c6721ad79ce5af44c8eca3517db7b66ac7afe3f /src
parent3086e2542b0e0e41f286b6e80041b473966df882 (diff)
downloadfengari-5b564fb8e230f98b672aea534c16d7d99ffe1944.tar.gz
fengari-5b564fb8e230f98b672aea534c16d7d99ffe1944.tar.bz2
fengari-5b564fb8e230f98b672aea534c16d7d99ffe1944.zip
src/lapi.js: Keep empty string constant around
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 2ae5b3c..0c1a3a6 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -230,15 +230,18 @@ const lua_pushinteger = function(L, n) {
assert(L.top <= L.ci.top, "stack overflow");
};
+const emptystring = [];
+
const lua_pushlstring = function(L, s, len) {
assert(typeof len === "number");
let ts;
if (len === 0) {
- ts = lstring.luaS_bless(L, []);
+ s = emptystring;
} else {
assert(defs.is_luastring(s) && s.length >= len, "lua_pushlstring expects array of byte");
- ts = lstring.luaS_bless(L, s.slice(0, len));
+ s = s.slice(0, len);
}
+ ts = lstring.luaS_bless(L, s);
lobject.pushsvalue2s(L, ts);
assert(L.top <= L.ci.top, "stack overflow");
@@ -1055,7 +1058,7 @@ const lua_concat = function(L, n) {
if (n >= 2)
lvm.luaV_concat(L, n);
else if (n === 0) {
- lobject.pushsvalue2s(L, lstring.luaS_bless(L, []));
+ lobject.pushsvalue2s(L, lstring.luaS_bless(L, emptystring));
assert(L.top <= L.ci.top, "stack overflow");
}
};