mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
Fix in-place removal
This commit is contained in:
parent
3b65a58f59
commit
2546930a1a
@ -403,16 +403,18 @@ func ensureNodePresent(nodes []NodeConfiguration, myID protocol.NodeID) []NodeCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ensureExistingNodes(nodes []NodeConfiguration, existingNodes map[protocol.NodeID]bool) []NodeConfiguration {
|
func ensureExistingNodes(nodes []NodeConfiguration, existingNodes map[protocol.NodeID]bool) []NodeConfiguration {
|
||||||
|
count := len(nodes)
|
||||||
i := 0
|
i := 0
|
||||||
for _, node := range nodes {
|
loop:
|
||||||
if _, ok := existingNodes[node.NodeID]; !ok {
|
for i < count {
|
||||||
last := len(nodes) - 1
|
if _, ok := existingNodes[nodes[i].NodeID]; !ok {
|
||||||
nodes[i] = nodes[last]
|
nodes[i] = nodes[count-1]
|
||||||
nodes = nodes[:last]
|
count--
|
||||||
} else {
|
continue loop
|
||||||
i++
|
|
||||||
}
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
|
nodes = nodes[0:count]
|
||||||
|
|
||||||
sort.Sort(NodeConfigurationList(nodes))
|
sort.Sort(NodeConfigurationList(nodes))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user