Refactor: streamline Node.WithParents()

Make it take parameters just like all the callers have, instead of
making them create a different structure.

It is now only used in tests.
This commit is contained in:
Bryan Boreham
2018-07-20 19:57:44 +00:00
parent 67052a6580
commit 1ed07f4a0a
5 changed files with 112 additions and 175 deletions

View File

@@ -18,13 +18,13 @@ func Prune(nodes report.Nodes) report.Nodes {
// necessary for rendering nodes and edges stripped away. Specifically, that
// means cutting out parts of the Node.
func PruneNode(node report.Node) report.Node {
prunedChildren := report.MakeNodeSet()
prunedChildren := []report.Node{}
node.Children.ForEach(func(child report.Node) {
prunedChildren = prunedChildren.Add(PruneNode(child))
prunedChildren = append(prunedChildren, PruneNode(child))
})
return report.MakeNode(
node.ID).
WithTopology(node.Topology).
WithAdjacent(node.Adjacency...).
WithChildren(prunedChildren)
WithChildren(prunedChildren...)
}