Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fly-by optimisation
Browse files Browse the repository at this point in the history
save a few allocations
rade committed Dec 28, 2017
1 parent 331d09a commit 605383b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions render/metrics.go
Original file line number Diff line number Diff line change
@@ -21,16 +21,20 @@ func (p propagateSingleMetrics) Render(rpt report.Report) Nodes {
nodes := p.r.Render(rpt)
outputs := make(report.Nodes, len(nodes.Nodes))
for id, n := range nodes.Nodes {
var found []report.Node
var first report.Node
found := 0
n.Children.ForEach(func(child report.Node) {
if child.Topology == p.topology {
if _, ok := child.Latest.Lookup(report.DoesNotMakeConnections); !ok {
found = append(found, child)
if found == 0 {
first = child
}
found++
}
}
})
if len(found) == 1 {
n = n.WithMetrics(found[0].Metrics)
if found == 1 {
n = n.WithMetrics(first.Metrics)
}
outputs[id] = n
}

0 comments on commit 605383b

Please sign in to comment.