aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-22 10:36:43 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-22 10:36:43 +1000
commit02cc918af02b60f65c2622a2ee09e033f52d69b6 (patch)
tree7d39b4be19087b0f7c4239fdbd74d67065926f3a
parentc82d2525a086317570dfbf0481c15d385c32726e (diff)
downloadfengari-02cc918af02b60f65c2622a2ee09e033f52d69b6.tar.gz
fengari-02cc918af02b60f65c2622a2ee09e033f52d69b6.tar.bz2
fengari-02cc918af02b60f65c2622a2ee09e033f52d69b6.zip
src/lstrlib.js: Remove useless copies in num2straux
-rw-r--r--src/lstrlib.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 9a75b78..1397039 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -95,7 +95,6 @@ const adddigit = function(buff, n, x) {
};
const num2straux = function(x) {
- let buff = [];
/* if 'inf' or 'NaN', format it like '%g' */
if (Object.is(x, Infinity))
return lua.to_luastring('inf', true);
@@ -110,6 +109,7 @@ const num2straux = function(x) {
return ['-'.charCodeAt(0)].concat(zero);
return zero;
} else {
+ let buff = [];
let fe = luaconf.frexp(x); /* 'x' fraction and exponent */
let m = fe[0];
let e = fe[1];
@@ -128,8 +128,8 @@ const num2straux = function(x) {
m = adddigit(buff, n++, m * 16);
} while (m > 0);
}
- let exp = sprintf("p%+d", e).split('').map(e => e.charCodeAt(0));
- return buff.slice(0, n + 1).concat(exp).concat(buff.slice(n));
+ let exp = lua.to_luastring(sprintf("p%+d", e));
+ return buff.concat(exp);
}
};