diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-05-07 03:36:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-06 21:36:57 +0200 |
commit | b562e1e6d85d5c64eec1d714257e2f728e60f12f (patch) | |
tree | 67c4dad9040ab9164cabf578695e366b020efc33 /lib/system | |
parent | ba698d37c3254072a3bb946d3750ceaf450da7b4 (diff) | |
download | Nim-b562e1e6d85d5c64eec1d714257e2f728e60f12f.tar.gz |
implement `=dup` hook eliminating `wasMoved` and `=copy` pairs (#21586)
* import `=dup` hook eliminating `wasMoved` and `=copy` pairs * add dup * add a test for dup * fixes documentation * fixes signature * resolve comments * fixes tests * fixes tests * clean up
Diffstat (limited to 'lib/system')
-rw-r--r-- | lib/system/arc.nim | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/system/arc.nim b/lib/system/arc.nim index d8527e1e4..55c4c412a 100644 --- a/lib/system/arc.nim +++ b/lib/system/arc.nim @@ -185,6 +185,10 @@ proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} = when traceCollector: cprintf("[DeCREF] %p\n", cell) +proc nimDupRef(dest: ptr pointer, src: pointer) {.compilerRtl, inl.} = + dest[] = src + if src != nil: nimIncRef src + proc GC_unref*[T](x: ref T) = ## New runtime only supports this operation for 'ref T'. var y {.cursor.} = x |