arc/orc lacks `shallowCopy` --> use `move` (#630)

`shallowCopy` is not available in `--mm:arc/orc`, but our usage can be
replaced with `move`.
This commit is contained in:
Etan Kissling 2023-08-15 14:48:41 +02:00 committed by GitHub
parent 2ed8e991b5
commit 946ffe0a4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -485,10 +485,16 @@ func len*(r: RoutingTable): int =
func moveRight[T](arr: var openArray[T], a, b: int) = func moveRight[T](arr: var openArray[T], a, b: int) =
## In `arr` move elements in range [a, b] right by 1. ## In `arr` move elements in range [a, b] right by 1.
var t: T var t: T
when declared(shallowCopy):
shallowCopy(t, arr[b + 1]) shallowCopy(t, arr[b + 1])
for i in countdown(b, a): for i in countdown(b, a):
shallowCopy(arr[i + 1], arr[i]) shallowCopy(arr[i + 1], arr[i])
shallowCopy(arr[a], t) shallowCopy(arr[a], t)
else:
t = move arr[b + 1]
for i in countdown(b, a):
arr[i + 1] = move arr[i]
arr[a] = move t
proc setJustSeen*(r: RoutingTable, n: Node) = proc setJustSeen*(r: RoutingTable, n: Node) =
## Move `n` to the head (most recently seen) of its bucket. ## Move `n` to the head (most recently seen) of its bucket.