mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-18 20:07:06 +00:00
get rid of Node.Copy()
A shallow copy is sufficient. Which we get for free in most cases since Node is passed around by value.
This commit is contained in:
committed by
Alfonso Acosta
parent
e42444c2e5
commit
1091225bf6
+7
-9
@@ -191,13 +191,12 @@ func (r containerWithImageNameRenderer) Render(rpt report.Report, dct Decorator)
|
||||
imageNameWithoutVersion := docker.ImageNameWithoutVersion(imageName)
|
||||
imageNodeID := report.MakeContainerImageNodeID(imageNameWithoutVersion)
|
||||
|
||||
output := c.Copy()
|
||||
output = propagateLatest(docker.ImageName, image, output)
|
||||
output = propagateLatest(docker.ImageLabelPrefix+"works.weave.role", image, output)
|
||||
output.Parents = output.Parents.
|
||||
c = propagateLatest(docker.ImageName, image, c)
|
||||
c = propagateLatest(docker.ImageLabelPrefix+"works.weave.role", image, c)
|
||||
c.Parents = c.Parents.
|
||||
Delete(report.ContainerImage).
|
||||
Add(report.ContainerImage, report.MakeStringSet(imageNodeID))
|
||||
outputs[id] = output
|
||||
outputs[id] = c
|
||||
}
|
||||
return outputs
|
||||
}
|
||||
@@ -365,14 +364,13 @@ func MapContainerImage2Name(n report.Node, _ report.Networks) report.Nodes {
|
||||
}
|
||||
|
||||
imageNameWithoutVersion := docker.ImageNameWithoutVersion(imageName)
|
||||
output := n.Copy()
|
||||
output.ID = report.MakeContainerImageNodeID(imageNameWithoutVersion)
|
||||
n.ID = report.MakeContainerImageNodeID(imageNameWithoutVersion)
|
||||
|
||||
if imageID, ok := report.ParseContainerImageNodeID(n.ID); ok {
|
||||
output.Sets = output.Sets.Add(docker.ImageID, report.EmptyStringSet.Add(imageID))
|
||||
n.Sets = n.Sets.Add(docker.ImageID, report.EmptyStringSet.Add(imageID))
|
||||
}
|
||||
|
||||
return report.Nodes{output.ID: output}
|
||||
return report.Nodes{n.ID: n}
|
||||
}
|
||||
|
||||
// MapContainer2Hostname maps container Nodes to 'hostname' renderabled nodes..
|
||||
|
||||
@@ -75,7 +75,6 @@ func incomingConnectionsSummary(topologyID string, r report.Report, n report.Nod
|
||||
if !node.Adjacency.Contains(n.ID) {
|
||||
continue
|
||||
}
|
||||
remoteNode := node.Copy()
|
||||
|
||||
// Work out what port they are talking to, and count the number of
|
||||
// connections to that port.
|
||||
@@ -91,7 +90,7 @@ func incomingConnectionsSummary(topologyID string, r report.Report, n report.Nod
|
||||
}
|
||||
key := connection{
|
||||
localNode: &n,
|
||||
remoteNode: &remoteNode,
|
||||
remoteNode: &node,
|
||||
port: port,
|
||||
}
|
||||
if isInternetNode(n) {
|
||||
@@ -127,8 +126,7 @@ func outgoingConnectionsSummary(topologyID string, r report.Report, n report.Nod
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
remoteNode := node.Copy()
|
||||
remoteEndpointIDs := endpointChildIDsOf(remoteNode)
|
||||
remoteEndpointIDs := endpointChildIDsOf(node)
|
||||
|
||||
for _, localEndpoint := range localEndpoints {
|
||||
_, localAddr, _, ok := report.ParseEndpointNodeID(localEndpoint.ID)
|
||||
@@ -143,7 +141,7 @@ func outgoingConnectionsSummary(topologyID string, r report.Report, n report.Nod
|
||||
}
|
||||
key := connection{
|
||||
localNode: &n,
|
||||
remoteNode: &remoteNode,
|
||||
remoteNode: &node,
|
||||
port: port,
|
||||
}
|
||||
if isInternetNode(n) {
|
||||
|
||||
+3
-4
@@ -63,12 +63,11 @@ func (r processWithContainerNameRenderer) Render(rpt report.Report, dct Decorato
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
output := p.Copy()
|
||||
output.Latest = output.Latest.Set(docker.ContainerID, timestamp, containerID)
|
||||
p.Latest = p.Latest.Set(docker.ContainerID, timestamp, containerID)
|
||||
if containerName, timestamp, ok := container.Latest.LookupEntry(docker.ContainerName); ok {
|
||||
output.Latest = output.Latest.Set(docker.ContainerName, timestamp, containerName)
|
||||
p.Latest = p.Latest.Set(docker.ContainerName, timestamp, containerName)
|
||||
}
|
||||
outputs[id] = output
|
||||
outputs[id] = p
|
||||
}
|
||||
return outputs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user