gc:destructors: progress
This commit is contained in:
parent
9563be37d3
commit
728ff1004a
6 changed files with 85 additions and 2 deletions
|
|
@ -118,7 +118,7 @@ proc shrink*[T](x: var seq[T]; newLen: Natural) =
|
|||
when not supportsCopyMem(T):
|
||||
for i in countdown(x.len - 1, newLen - 1):
|
||||
`=destroy`(x[i])
|
||||
|
||||
# XXX This is wrong for const seqs that were moved into 'x'!
|
||||
cast[ptr NimSeqV2[T]](addr x).len = newLen
|
||||
|
||||
proc grow*[T](x: var seq[T]; newLen: Natural; value: T) =
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ proc mnewString(len: int): NimStringV2 {.compilerProc.} =
|
|||
proc setLengthStrV2(s: var NimStringV2, newLen: int) {.compilerRtl.} =
|
||||
if newLen > s.len:
|
||||
prepareAdd(s, newLen - s.len)
|
||||
# XXX This is wrong for const strings that got moved into 's'!
|
||||
s.len = newLen
|
||||
# this also only works because the destructor
|
||||
# looks at s.p and not s.len
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue