From 6ee08cf70c9461972cfcf179e12669b5518977ff Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 5 Dec 2017 13:53:18 +0100 Subject: fix documentation comments in sequtils.nim --- lib/pure/collections/sequtils.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/pure/collections/sequtils.nim b/lib/pure/collections/sequtils.nim index d0f5c78e0..06e96ca36 100644 --- a/lib/pure/collections/sequtils.nim +++ b/lib/pure/collections/sequtils.nim @@ -66,7 +66,7 @@ proc cycle*[T](s: openArray[T], n: Natural): seq[T] = ## ## Example: ## - ## .. code-block: + ## .. code-block:: ## ## let ## s = @[1, 2, 3] @@ -84,7 +84,7 @@ proc repeat*[T](x: T, n: Natural): seq[T] = ## ## Example: ## - ## .. code-block: + ## .. code-block:: ## ## let ## total = repeat(5, 3) -- cgit 1.4.1-2-gfad0 From e016c9253e7b02ad4781452067dad980c677f61e Mon Sep 17 00:00:00 2001 From: Brent Pedersen Date: Thu, 7 Dec 2017 12:25:39 -0700 Subject: optimize setLen (#6816) inline the call to setLengthSeq and avoid decref for types if ntfNoRefs closes #6721 and speeds setLen when newLen < len for non reference types. --- lib/system/sysstr.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index 3f8e0eff0..56b8ade97 100644 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -259,7 +259,7 @@ proc incrSeqV2(seq: PGenericSeq, elemSize: int): PGenericSeq {.compilerProc.} = result.reserved = r proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {. - compilerRtl.} = + compilerRtl, inl.} = result = seq if result.space < newLen: let r = max(resize(result.space), newLen) @@ -282,10 +282,11 @@ proc setLengthSeq(seq: PGenericSeq, elemSize, newLen: int): PGenericSeq {. doDecRef(gch.tempStack.d[i], LocalHeap, MaybeCyclic) gch.tempStack.len = len0 else: - for i in newLen..result.len-1: - forAllChildrenAux(cast[pointer](cast[ByteAddress](result) +% - GenericSeqSize +% (i*%elemSize)), - extGetCellType(result).base, waZctDecRef) + if ntfNoRefs notin extGetCellType(result).base.flags: + for i in newLen..result.len-1: + forAllChildrenAux(cast[pointer](cast[ByteAddress](result) +% + GenericSeqSize +% (i*%elemSize)), + extGetCellType(result).base, waZctDecRef) # XXX: zeroing out the memory can still result in crashes if a wiped-out # cell is aliased by another pointer (ie proc parameter or a let variable). -- cgit 1.4.1-2-gfad0