mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-18 04:49:55 +00:00
remove superfluous lookups
Since we seed the joinResult with the nodes from the topology we are mapping to, we know the 'create' function is only called when there is no node with the specified id. This neatly makes the 'create' function only do what it says, i.e. return _new_ nodes.
This commit is contained in:
@@ -94,9 +94,8 @@ func (c connectionJoin) Render(rpt report.Report) Nodes {
|
||||
id, found = ipNodes[report.MakeScopedEndpointNodeID(scope, addr, port)]
|
||||
}
|
||||
if found && id != "" { // not one we blanked out earlier
|
||||
ret.addChild(m, id, func(id string) report.Node {
|
||||
return inputNodes.Nodes[id]
|
||||
})
|
||||
// We are guaranteed to find the id, so no need to pass a node constructor.
|
||||
ret.addChild(m, id, nil)
|
||||
}
|
||||
}
|
||||
return ret.result(endpoints)
|
||||
|
||||
@@ -62,9 +62,6 @@ func (e endpoints2Hosts) Render(rpt report.Report) Nodes {
|
||||
} else {
|
||||
id := report.MakeHostNodeID(report.ExtractHostID(n))
|
||||
ret.addChild(n, id, func(id string) report.Node {
|
||||
if hostNode, found := hosts.Nodes[id]; found {
|
||||
return hostNode
|
||||
}
|
||||
// we have a hostNodeID, but no matching host node;
|
||||
// create a new one rather than dropping the data
|
||||
return report.MakeNode(id).WithTopology(report.Host).
|
||||
|
||||
@@ -106,10 +106,8 @@ func (e endpoints2Processes) Render(rpt report.Report) Nodes {
|
||||
hostID, _, _ := report.ParseNodeID(hostNodeID)
|
||||
id := report.MakeProcessNodeID(hostID, pid)
|
||||
ret.addChild(n, id, func(id string) report.Node {
|
||||
if processNode, found := processes.Nodes[id]; found {
|
||||
return processNode
|
||||
}
|
||||
// we have a pid, but no matching process node; create a new one rather than dropping the data
|
||||
// we have a pid, but no matching process node;
|
||||
// create a new one rather than dropping the data
|
||||
return report.MakeNode(id).WithTopology(report.Process).
|
||||
WithLatest(process.PID, timestamp, pid)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user