From 8f188fb2f792223f1a0c1730bd4ac99418d81d74 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 9 Jun 2017 14:29:54 +1000 Subject: Avoid .concat where simple to do so --- src/lauxlib.js | 4 ++-- src/ldblib.js | 2 +- src/lstrlib.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lauxlib.js b/src/lauxlib.js index 84b625e..2f86720 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -110,7 +110,7 @@ const luaL_traceback = function(L, L1, msg, level) { let last = lastlevel(L1); let n1 = last - level > LEVELS1 + LEVELS2 ? LEVELS1 : -1; if (msg) - lua.lua_pushstring(L, msg.concat('\n'.charCodeAt(0))); + lua.lua_pushfstring(L, lua.to_luastring("%s\n"), msg); luaL_checkstack(L, 10, null); lua.lua_pushliteral(L, "stack traceback:"); while (lua.lua_getstack(L1, level++, ar)) { @@ -119,7 +119,7 @@ const luaL_traceback = function(L, L1, msg, level) { level = last - LEVELS2 + 1; /* and skip to last ones */ } else { lua.lua_getinfo(L1, lua.to_luastring("Slnt", true), ar); - lua.lua_pushstring(L, ['\n'.charCodeAt(0), '\t'.charCodeAt(0)].concat(ar.short_src).concat([':'.charCodeAt(0)])); + lua.lua_pushfstring(L, lua.to_luastring("\n\t%s:"), ar.short_src); if (ar.currentline > 0) lua.lua_pushliteral(L, `${ar.currentline}:`); lua.lua_pushliteral(L, " in "); diff --git a/src/ldblib.js b/src/ldblib.js index ac3a2a4..441dec0 100644 --- a/src/ldblib.js +++ b/src/ldblib.js @@ -123,7 +123,7 @@ const db_getinfo = function(L) { let options = lauxlib.luaL_optstring(L, arg + 2, lua.to_luastring("flnStu", true)); checkstack(L, L1, 3); if (lua.lua_isfunction(L, arg + 1)) { /* info about a function? */ - options = ['>'.charCodeAt(0)].concat(options); /* add '>' to 'options' */ + options = lua.lua_pushfstring(L, lua.to_luastring(">%s"), options); /* add '>' to 'options' */ lua.lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ lua.lua_xmove(L, L1, 1); } else { /* stack level */ diff --git a/src/lstrlib.js b/src/lstrlib.js index 0fb8631..4b83ac1 100644 --- a/src/lstrlib.js +++ b/src/lstrlib.js @@ -103,10 +103,10 @@ const num2straux = function(x) { return lua.to_luastring('nan', true).slice(0); else if (x === 0) { /* can be -0... */ /* create "0" or "-0" followed by exponent */ - let zero = sprintf(luaconf.LUA_NUMBER_FMT + "x0p+0", x).split('').map(e => e.charCodeAt(0)); + let zero = sprintf(luaconf.LUA_NUMBER_FMT + "x0p+0", x); if (Object.is(x, -0)) - return ['-'.charCodeAt(0)].concat(zero); - return zero; + zero = "-" + zero; + return lua.to_luastring(zero); } else { let buff = []; let fe = luaconf.frexp(x); /* 'x' fraction and exponent */ -- cgit v1.2.3-70-g09d2