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:
parent
1d615dfda7
commit
fa1a04188f
1 changed files with 2 additions and 3 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue