mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 18:51:17 +00:00
Merge pull request #3143 from weaveworks/unsafe-add-children
Use unsafe merge in joinResults.addChildAndChildren()
This commit is contained in:
@@ -169,6 +169,7 @@ func (ret *joinResults) mapChild(from, to string) {
|
||||
}
|
||||
|
||||
// Add m into the results as a top-level node, mapped from original ID
|
||||
// Note it is not safe to mix calls to add() with addChild(), addChildAndChildren() or addUnmappedChild()
|
||||
func (ret *joinResults) add(from string, m report.Node) {
|
||||
if existing, ok := ret.nodes[m.ID]; ok {
|
||||
m = m.Merge(existing)
|
||||
@@ -203,7 +204,7 @@ func (ret *joinResults) addChild(m report.Node, id string, topology string) {
|
||||
func (ret *joinResults) addChildAndChildren(m report.Node, id string, topology string) {
|
||||
ret.addUnmappedChild(m, id, topology)
|
||||
result := ret.nodes[id]
|
||||
result.Children = result.Children.Merge(m.Children)
|
||||
result.Children.UnsafeMerge(m.Children)
|
||||
ret.nodes[id] = result
|
||||
ret.mapChild(m.ID, id)
|
||||
}
|
||||
|
||||
@@ -72,6 +72,13 @@ func (n NodeSet) Delete(ids ...string) NodeSet {
|
||||
return NodeSet{result}
|
||||
}
|
||||
|
||||
// UnsafeMerge combines the two NodeSets, altering n
|
||||
func (n *NodeSet) UnsafeMerge(other NodeSet) {
|
||||
other.psMap.ForEach(func(key string, otherVal interface{}) {
|
||||
n.psMap = n.psMap.UnsafeMutableSet(key, otherVal)
|
||||
})
|
||||
}
|
||||
|
||||
// Merge combines the two NodeSets and returns a new result.
|
||||
func (n NodeSet) Merge(other NodeSet) NodeSet {
|
||||
nSize, otherSize := n.Size(), other.Size()
|
||||
|
||||
Reference in New Issue
Block a user