Move wasMoved out of =destroy

This commit is contained in:
Clyybber 2020-07-08 20:48:17 +02:00 • committed by Andreas Rumpf
commit 4a1128d16c
5 changed files with 9 additions and 19 deletions

View file

@ -73,11 +73,10 @@ proc shrink*[T](x: var seq[T]; newLen: Natural) =
when nimvm:
setLen(x, newLen)
else:
mixin `=destroy`
#sysAssert newLen <= x.len, "invalid newLen parameter for 'shrink'"
when not supportsCopyMem(T):
for i in countdown(x.len - 1, newLen):
`=destroy`(x[i])
reset x[i]
# XXX This is wrong for const seqs that were moved into 'x'!
cast[ptr NimSeqV2[T]](addr x).len = newLen