summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-13 14:56:26 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-13 15:31:07 +1100
commit17e4cff6514c75920462397c227408c21336d1ae (patch)
tree2a3768d78a30f77adbc52231ac61909e64794a48 /src
parent11a2421acaf2b39d19ee99933102c35e28fd13f8 (diff)
downloadfengari-17e4cff6514c75920462397c227408c21336d1ae.tar.gz
fengari-17e4cff6514c75920462397c227408c21336d1ae.tar.bz2
fengari-17e4cff6514c75920462397c227408c21336d1ae.zip
src/: Use .subarray instead of .slice (optimisation)
Diffstat (limited to 'src')
-rw-r--r--src/lauxlib.js2
-rw-r--r--src/llex.js4
-rw-r--r--src/lobject.js6
-rw-r--r--src/lundump.js2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 6acf57f..3b2be6e 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -62,7 +62,7 @@ const pushglobalfuncname = function(L, ar) {
if (findfield(L, top + 1, 2)) {
let name = lua.lua_tostring(L, -1);
if (name[0] === "_".charCodeAt(0) && name[1] === "G".charCodeAt(0) && name[2] === ".".charCodeAt(0)) { /* name start with '_G.'? */
- lua.lua_pushstring(L, name.slice(3)); /* push name without prefix */
+ lua.lua_pushstring(L, name.subarray(3)); /* push name without prefix */
lua.lua_remove(L, -2); /* remove original name */
}
lua.lua_copy(L, -1, top + 1); /* move name to proper place */
diff --git a/src/llex.js b/src/llex.js
index 9e4bed4..438f288 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -328,7 +328,7 @@ const read_long_string = function(ls, seminfo, sep) {
}
if (seminfo)
- seminfo.ts = luaX_newstring(ls, ls.buff.buffer.slice(2 + sep, ls.buff.n - (2 + sep)));
+ seminfo.ts = luaX_newstring(ls, ls.buff.buffer.subarray(2 + sep, ls.buff.n - (2 + sep)));
};
const esccheck = function(ls, c, msg) {
@@ -453,7 +453,7 @@ const read_string = function(ls, del, seminfo) {
}
save_and_next(ls); /* skip delimiter */
- seminfo.ts = luaX_newstring(ls, ls.buff.buffer.slice(1, ls.buff.n-1));
+ seminfo.ts = luaX_newstring(ls, ls.buff.buffer.subarray(1, ls.buff.n-1));
};
const token_to_index = Object.create(null); /* don't want to return true for e.g. 'hasOwnProperty' */
diff --git a/src/lobject.js b/src/lobject.js
index 18adb27..5ca7cd3 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -531,7 +531,7 @@ const luaO_pushvfstring = function(L, fmt, argp) {
for (;;) {
e = fmt.indexOf(char['%'], i);
if (e == -1) break;
- pushstr(L, fmt.slice(i, e));
+ pushstr(L, fmt.subarray(i, e));
switch(fmt[e+1]) {
case char['s']: {
let s = argp[a++];
@@ -540,7 +540,7 @@ const luaO_pushvfstring = function(L, fmt, argp) {
/* respect null terminator */
let i = s.indexOf(0);
if (i !== -1)
- s = s.slice(0, i);
+ s = s.subarray(0, i);
}
pushstr(L, s);
break;
@@ -609,7 +609,7 @@ const luaO_pushvfstring = function(L, fmt, argp) {
i = e + 2;
}
ldo.luaD_checkstack(L, 1);
- pushstr(L, fmt.slice(i));
+ pushstr(L, fmt.subarray(i));
if (n > 0) lvm.luaV_concat(L, n+1);
return L.stack[L.top-1].svalue();
};
diff --git a/src/lundump.js b/src/lundump.js
index 7461813..e49c376 100644
--- a/src/lundump.js
+++ b/src/lundump.js
@@ -25,7 +25,7 @@ class BytecodeParser {
assert(defs.is_luastring(name));
if (name[0] == defs.char["@"] || name[0] == defs.char["="])
- this.name = name.slice(1);
+ this.name = name.subarray(1);
else if (name[0] == defs.LUA_SIGNATURE.charCodeAt(0))
this.name = defs.to_luastring("binary string", true);
else