From e5cb1a2dd547827ee750abbb21039d1cf0a30988 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 24 Sep 2017 01:22:48 +0200 Subject: [PATCH] newSeqOfCap: skip initialization step for non-GC-ed data --- lib/system/mmdisp.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim index d2160fdac4..8249349669 100644 --- a/lib/system/mmdisp.nim +++ b/lib/system/mmdisp.nim @@ -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