summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-01-07 03:15:37 +1100
committerdaurnimator <quae@daurnimator.com>2018-01-07 03:35:01 +1100
commita63de72aa0bf0b1b3bd91ed0c23c4d03bcbf4cd5 (patch)
treef0ab04d4f8f5d29fa3564d391a3f0b1cd7ece2c2
parent2d466624e05596a851cea18356dae8ae5f5d32f0 (diff)
downloadfengari-a63de72aa0bf0b1b3bd91ed0c23c4d03bcbf4cd5.tar.gz
fengari-a63de72aa0bf0b1b3bd91ed0c23c4d03bcbf4cd5.tar.bz2
fengari-a63de72aa0bf0b1b3bd91ed0c23c4d03bcbf4cd5.zip
src/lstrlib.js: Remove use of Uint8Array.reverse
-rw-r--r--src/lstrlib.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lstrlib.js b/src/lstrlib.js
index e31c0fe..6cb8df9 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -595,7 +595,12 @@ const str_pack = function(L) {
};
const str_reverse = function(L) {
- lua.lua_pushstring(L, lauxlib.luaL_checkstring(L, 1).slice(0).reverse());
+ let s = lauxlib.luaL_checkstring(L, 1);
+ let l = s.length;
+ let r = new Uint8Array(l);
+ for (let i=0; i<l; i++)
+ r[i] = s[l-1-i];
+ lua.lua_pushstring(L, r);
return 1;
};