Skip to content

Commit 9f9cb27

Browse files
committed
Downgrade to setlen when not (nimSeqsV2 or hasAlloc)
Without `hasAlloc` `system/sysstr` is not included in system so `setLengthStrUninit` is not in the scope.
1 parent 059a3f9 commit 9f9cb27

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/system.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,10 @@ func setLenUninit*(s: var string, newlen: Natural) {.nodestroy.} =
23202320
setLengthStrV2Uninit(cast[ptr NimStringV2](str)[], newlen)
23212321
else:
23222322
{.noSideEffect.}:
2323-
setLengthStrUninit(s, newlen)
2323+
when hasAlloc:
2324+
setLengthStrUninit(s, newlen)
2325+
else:
2326+
s.setLen(n)
23242327
else: s.setLen(n)
23252328

23262329

lib/system/strs_v2.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ proc setLengthStrV2(s: var NimStringV2, newLen: int) {.compilerRtl.} =
166166
s.p.data[newLen] = '\0'
167167
s.len = newLen
168168

169-
proc setLengthStrV2Uninit(s: var NimStringV2, newLen: int) =
169+
proc setLengthStrV2Uninit(s: var NimStringV2, newLen: int) =
170170
if newLen == 0:
171171
discard "do not free the buffer here, pattern 's.setLen 0' is common for avoiding allocations"
172172
else:

0 commit comments

Comments
 (0)