summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-05-21 22:38:13 +0200
committerGitHub <noreply@github.com>2020-05-21 22:38:13 +0200
commit3eaa870c0a3ac0a97c1726278412141140d35b9b (patch)
tree75488d3b49e535f283f77e411cee6e8447d3fc6b /lib
parentddee8a362a6590d8e590e6804e31b79bdb9ab7e6 (diff)
downloadNim-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.nim3
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)