Skip to content

Commit

Permalink
arc/orc lacks shallowCopy --> use move (#630)
Browse files Browse the repository at this point in the history
`shallowCopy` is not available in `--mm:arc/orc`, but our usage can be
replaced with `move`.
  • Loading branch information
etan-status committed Aug 15, 2023
1 parent 2ed8e99 commit 946ffe0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions eth/p2p/discoveryv5/routing_table.nim
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,16 @@ func len*(r: RoutingTable): int =
func moveRight[T](arr: var openArray[T], a, b: int) =
## In `arr` move elements in range [a, b] right by 1.
var t: T
shallowCopy(t, arr[b + 1])
for i in countdown(b, a):
shallowCopy(arr[i + 1], arr[i])
shallowCopy(arr[a], t)
when declared(shallowCopy):
shallowCopy(t, arr[b + 1])
for i in countdown(b, a):
shallowCopy(arr[i + 1], arr[i])
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) =
## Move `n` to the head (most recently seen) of its bucket.
Expand Down

0 comments on commit 946ffe0

Please sign in to comment.