fixes #25007; implements setLenUninit for refc (#25022)

fixes #25007

```nim
proc setLengthSeqUninit(s: PGenericSeq, typ: PNimType, newLen: int, isTrivial: bool): PGenericSeq {.
    compilerRtl.} =
```

In this added function, only the line `zeroMem(dataPointer(result,
elemAlign, elemSize, newLen), (result.len-%newLen) *% elemSize)` is
removed from `proc setLengthSeqV2` when enlarging a sequence.

JS and VM versions simply use `setLen`.
This commit is contained in:
ringabout
2025-07-15 05:19:58 +08:00
committed by GitHub
parent 7e2df41850
commit 611b8bbf67
13 changed files with 79 additions and 7 deletions

View File

@@ -236,5 +236,12 @@ proc bar2() =
doAssert cstring(nil) <= cstring(nil)
doAssert cstring("") <= cstring("")
var x = @[10, 20]
x.setLenUninit(5)
x[4] = 50
doAssert x[4] == 50
x.setLenUninit(1)
doAssert x == @[10]
static: bar2()
bar2()