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:
Matthias Radestock
2017-12-17 16:55:38 +00:00
parent ac87c2b6e8
commit a6f24fc151
3 changed files with 4 additions and 10 deletions

View File

@@ -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)

View File

@@ -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).

View File

@@ -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)
})