Fix add(string, cstring) when the lhs is null (#8951)
This commit is contained in:
parent
87955eaf30
commit
b195204549
2 changed files with 8 additions and 3 deletions
|
|
@ -2741,10 +2741,11 @@ type
|
|||
when defined(JS):
|
||||
proc add*(x: var string, y: cstring) {.asmNoStackFrame.} =
|
||||
asm """
|
||||
var len = `x`.length;
|
||||
if (`x` === null) { `x` = []; }
|
||||
var off = `x`.length;
|
||||
`x`.length += `y`.length;
|
||||
for (var i = 0; i < `y`.length; ++i) {
|
||||
`x`[len] = `y`.charCodeAt(i);
|
||||
++len;
|
||||
`x`[off+i] = `y`.charCodeAt(i);
|
||||
}
|
||||
"""
|
||||
proc add*(x: var cstring, y: cstring) {.magic: "AppendStrStr".}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue