diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-05-21 22:38:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 22:38:13 +0200 |
commit | 3eaa870c0a3ac0a97c1726278412141140d35b9b (patch) | |
tree | 75488d3b49e535f283f77e411cee6e8447d3fc6b /lib | |
parent | ddee8a362a6590d8e590e6804e31b79bdb9ab7e6 (diff) | |
download | Nim-3eaa870c0a3ac0a97c1726278412141140d35b9b.tar.gz |
ARC/ORC: optimize s.setLen(0) to match the old runtime's behaviour (#14423)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/strs_v2.nim | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/system/strs_v2.nim b/lib/system/strs_v2.nim index 3beb14382..aa644522f 100644 --- a/lib/system/strs_v2.nim +++ b/lib/system/strs_v2.nim @@ -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) |