mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
fly-by optimisation
save a few allocations
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user