From a6f24fc151f7c1e20ca2bc0050735663e4c41ede Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sun, 17 Dec 2017 16:55:38 +0000 Subject: [PATCH] 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. --- render/container.go | 5 ++--- render/host.go | 3 --- render/process.go | 6 ++---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/render/container.go b/render/container.go index 540e284c0..219a76d9c 100644 --- a/render/container.go +++ b/render/container.go @@ -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) diff --git a/render/host.go b/render/host.go index d8f39205f..180f1115d 100644 --- a/render/host.go +++ b/render/host.go @@ -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). diff --git a/render/process.go b/render/process.go index bd5c321dc..f1ca648e2 100644 --- a/render/process.go +++ b/render/process.go @@ -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) })