From d8e002a33c6b212891d09a2221edd0f516d13d9a Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 13 Dec 2017 14:38:52 +1100 Subject: src/lapi.js: Remove emptystring: rely on internal string cache instead --- src/lapi.js | 8 +++----- src/ldebug.js | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lapi.js b/src/lapi.js index 9e2f0a3..afa94ce 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -230,13 +230,11 @@ const lua_pushinteger = function(L, n) { assert(L.top <= L.ci.top, "stack overflow"); }; -const emptystring = defs.to_luastring(""); - const lua_pushlstring = function(L, s, len) { assert(typeof len === "number"); let ts; if (len === 0) { - s = emptystring; + s = defs.to_luastring("", true); } else { assert(defs.is_luastring(s) && s.length >= len, "lua_pushlstring expects array of byte"); s = s.slice(0, len); @@ -525,7 +523,7 @@ const aux_upvalue = function(L, fi, n) { let f = fi.value; if (!(1 <= n && n <= f.nupvalues)) return null; return { - name: [], + name: defs.to_luastring("", true), val: f.upvalue[n-1] }; } @@ -1059,7 +1057,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, emptystring)); + lobject.pushsvalue2s(L, lstring.luaS_bless(L, defs.to_luastring("", true))); assert(L.top <= L.ci.top, "stack overflow"); } }; diff --git a/src/ldebug.js b/src/ldebug.js index 58bccc9..c93df91 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -247,7 +247,7 @@ const auxgetinfo = function(L, what, ar, f, ci) { case 'n': { let r = getfuncname(L, ci); if (r === null) { - ar.namewhat = defs.to_luastring(""); + ar.namewhat = defs.to_luastring("", true); ar.name = null; } else { ar.namewhat = r.funcname; -- cgit v1.2.3-54-g00ecf