mirror of https://github.com/status-im/nim-eth.git
refactor: replace shallowCopy with something else
This commit is contained in:
parent
64b56d866c
commit
d238693571
|
@ -132,7 +132,8 @@ proc sendNeighbours*(d: DiscoveryProtocol, node: Node, neighbours: seq[Node]) =
|
||||||
const MAX_NEIGHBOURS_PER_PACKET = 12 # TODO: Implement a smarter way to compute it
|
const MAX_NEIGHBOURS_PER_PACKET = 12 # TODO: Implement a smarter way to compute it
|
||||||
type Neighbour = tuple[ip: IpAddress, udpPort, tcpPort: Port, pk: PublicKey]
|
type Neighbour = tuple[ip: IpAddress, udpPort, tcpPort: Port, pk: PublicKey]
|
||||||
var nodes = newSeqOfCap[Neighbour](MAX_NEIGHBOURS_PER_PACKET)
|
var nodes = newSeqOfCap[Neighbour](MAX_NEIGHBOURS_PER_PACKET)
|
||||||
shallow(nodes)
|
when not defined(nimSeqsV2):
|
||||||
|
shallow(nodes)
|
||||||
|
|
||||||
template flush() =
|
template flush() =
|
||||||
block:
|
block:
|
||||||
|
|
|
@ -482,10 +482,10 @@ proc len*(r: RoutingTable): int =
|
||||||
proc moveRight[T](arr: var openArray[T], a, b: int) =
|
proc 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
|
||||||
shallowCopy(t, arr[b + 1])
|
t = system.move(arr[b + 1])
|
||||||
for i in countdown(b, a):
|
for i in countdown(b, a):
|
||||||
shallowCopy(arr[i + 1], arr[i])
|
arr[i + 1] = system.move(arr[i])
|
||||||
shallowCopy(arr[a], t)
|
arr[a] = system.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.
|
||||||
|
|
Loading…
Reference in New Issue