Skip to content

Commit

Permalink
Use grow
Browse files Browse the repository at this point in the history
  • Loading branch information
AmjadHD committed Aug 21, 2023
1 parent 05427f9 commit 432b9f7
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/system/seqs_v2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,7 @@ proc setLen[T](s: var seq[T], newlen: Natural) =
if newlen < s.len:
shrink(s, newlen)
else:
let oldLen = s.len
if newlen <= oldLen: return
var xu = cast[ptr NimSeqV2[T]](addr s)
if xu.p == nil or (xu.p.cap and not strlitFlag) < newlen:
xu.p = cast[typeof(xu.p)](prepareSeqAdd(oldLen, xu.p, newlen - oldLen, sizeof(T), alignof(T)))
xu.len = newlen
for i in oldLen..<newlen:
xu.p.data[i] = default(T)
grow(s, newlen, default(T))

proc newSeq[T](s: var seq[T], len: Natural) =
shrink(s, 0)
Expand Down

0 comments on commit 432b9f7

Please sign in to comment.