newSeqOfCap: skip initialization step for non-GC-ed data
This commit is contained in:
parent
be2e7290fb
commit
e5cb1a2dd5
1 changed files with 5 additions and 1 deletions
|
|
@ -564,7 +564,11 @@ else:
|
|||
|
||||
when not declared(nimNewSeqOfCap):
|
||||
proc nimNewSeqOfCap(typ: PNimType, cap: int): pointer {.compilerproc.} =
|
||||
result = newObj(typ, addInt(mulInt(cap, typ.base.size), GenericSeqSize))
|
||||
let s = addInt(mulInt(cap, typ.base.size), GenericSeqSize)
|
||||
when declared(newObjNoInit):
|
||||
result = if ntfNoRefs in typ.base.flags: newObjNoInit(typ, s) else: newObj(typ, s)
|
||||
else:
|
||||
result = newObj(typ, s)
|
||||
cast[PGenericSeq](result).len = 0
|
||||
cast[PGenericSeq](result).reserved = cap
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue