Empty check in shallow [backport] (#9676)

This commit is contained in:
ishowta
2018-11-21 19:56:38 +09:00
committed by Andreas Rumpf
parent b78699917e
commit 6ff596d4f8
2 changed files with 25 additions and 0 deletions

View File

@@ -4017,6 +4017,7 @@ proc shallow*[T](s: var seq[T]) {.noSideEffect, inline.} =
## marks a sequence `s` as `shallow`:idx:. Subsequent assignments will not
## perform deep copies of `s`. This is only useful for optimization
## purposes.
if s.len == 0: return
when not defined(JS) and not defined(nimscript):
var s = cast[PGenericSeq](s)
s.reserved = s.reserved or seqShallowFlag