summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJonah Snider <jonah@jonah.pw>2020-12-27 00:33:51 -0800
committerGitHub <noreply@github.com>2020-12-27 09:33:51 +0100
commitfa1a04188ffdc66f1edc909e5b465e548532617a (patch)
treea19ebc293172f0737653cfac05622f92bd9aae2a
parent1d615dfda7102c5d7f190b077c0ae87abac34228 (diff)
downloadNim-fa1a04188ffdc66f1edc909e5b465e548532617a.tar.gz
Avoid creating a holey array in makeNimstrLit for JS target (#16461)
* Avoid creating a holey array in makeNimstrLit
* Use array index instead of push
-rw-r--r--lib/system/jssys.nim5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim
index 8865558fe..e2ceedc2c 100644
--- a/lib/system/jssys.nim
+++ b/lib/system/jssys.nim
@@ -189,9 +189,8 @@ proc setConstr() {.varargs, asmNoStackFrame, compilerproc.} =
 
 proc makeNimstrLit(c: cstring): string {.asmNoStackFrame, compilerproc.} =
   {.emit: """
-  var ln = `c`.length;
-  var result = new Array(ln);
-  for (var i = 0; i < ln; ++i) {
+  var result = [];
+  for (var i = 0; i < `c`.length; ++i) {
     result[i] = `c`.charCodeAt(i);
   }
   return result;