Created
May 14, 2019 06:55
-
-
Save Araq/d7771b542ec759d664f2be65b107d4ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when defined(nimOpMove): | |
proc `=move`[T](x, y: var seq[T]) = | |
mixin `=destroy` | |
if a.p != b.p: | |
var a = cast[ptr NimSeqV2[T]](addr x) | |
var b = cast[ptr NimSeqV2[T]](addr y) | |
if a.p != nil: `=destroy`(x) | |
a.len = b.len | |
a.p = b.p | |
# p is stolen, so afterwards it must be nil | |
b.p = nil | |
else: | |
proc `=sink`[T](x: var seq[T]; y: seq[T]) = | |
mixin `=destroy` | |
var a = cast[ptr NimSeqV2[T]](addr x) | |
var b = cast[ptr NimSeqV2[T]](unsafeAddr y) | |
if a.p != nil and a.p != b.p: | |
`=destroy`(x) | |
a.len = b.len | |
a.p = b.p |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment