ARC/ORC: optimize s.setLen(0) to match the old runtime's behaviour (#14423)
This commit is contained in:
parent
ddee8a362a
commit
3eaa870c0a
2 changed files with 2 additions and 3 deletions
|
|
@ -107,8 +107,7 @@ proc mnewString(len: int): NimStringV2 {.compilerproc.} =
|
|||
|
||||
proc setLengthStrV2(s: var NimStringV2, newLen: int) {.compilerRtl.} =
|
||||
if newLen == 0:
|
||||
frees(s)
|
||||
s.p = nil
|
||||
discard "do not free the buffer here, pattern 's.setLen 0' is common for avoiding allocations"
|
||||
else:
|
||||
if newLen > s.len or isLiteral(s):
|
||||
prepareAdd(s, newLen - s.len)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue