Avoid creating a holey array in makeNimstrLit for JS target (#16461)

* Avoid creating a holey array in makeNimstrLit
* Use array index instead of push
This commit is contained in:
Jonah Snider 2020-12-27 00:33:51 -08:00 • committed by GitHub
commit fa1a04188f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -189,9 +189,8 @@ proc setConstr() {.varargs, asmNoStackFrame, compilerproc.} =
proc makeNimstrLit(c: cstring): string {.asmNoStackFrame, compilerproc.} = proc makeNimstrLit(c: cstring): string {.asmNoStackFrame, compilerproc.} =
{.emit: """ {.emit: """
var ln = `c`.length; var result = [];
var result = new Array(ln); for (var i = 0; i < `c`.length; ++i) {
for (var i = 0; i < ln; ++i) {
result[i] = `c`.charCodeAt(i); result[i] = `c`.charCodeAt(i);
} }
return result; return result;