newSeqOfCap: skip initialization step for non-GC-ed data

This commit is contained in:
Andreas Rumpf
2017-09-24 01:22:48 +02:00
parent be2e7290fb
commit e5cb1a2dd5

View File

@@ -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