* Fix #14994

* Revert misplaced "optimization"

* Typo
This commit is contained in:
Clyybber
2020-07-15 23:33:58 +02:00
committed by GitHub
parent 617c1f16d7
commit 282128ab66
3 changed files with 17 additions and 1 deletions

View File

@@ -527,7 +527,8 @@ proc insert*[T](dest: var seq[T], src: openArray[T], pos = 0) =
assert dest == outcome
var j = len(dest) - 1
var i = len(dest) + len(src) - 1
var i = j + len(src)
if i == j: return
dest.setLen(i + 1)
# Move items after `pos` to the end of the sequence.

View File

@@ -82,6 +82,7 @@ proc shrink*[T](x: var seq[T]; newLen: Natural) =
proc grow*[T](x: var seq[T]; newLen: Natural; value: T) =
let oldLen = x.len
#sysAssert newLen >= x.len, "invalid newLen parameter for 'grow'"
if newLen <= oldLen: return
var xu = cast[ptr NimSeqV2[T]](addr x)
if xu.p == nil or xu.p.cap < newLen:

View File

@@ -21,6 +21,8 @@ whiley ends :(
(x: "9")
(x: "10")
0
new line before - @['a']
new line after - @['a']
closed
destroying variable: 20
destroying variable: 10
@@ -243,3 +245,15 @@ l.setParent(l)
# bug #14968
import times
let currentTime = now().utc
# bug #14994
import sequtils
var newLine = @['a']
let indent = newSeq[char]()
echo "new line before - ", newline
newline.insert(indent, 0)
echo "new line after - ", newline