mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-19 04:16:21 +00:00
AddParent() function to optimise the case where there is only one parent
Avoids creating and discarding a StringSet just to carry the parameters, and makes the code more readable too.
This commit is contained in:
@@ -152,6 +152,12 @@ func (n Node) WithLatestControl(control string, ts time.Time, data NodeControlDa
|
||||
return n
|
||||
}
|
||||
|
||||
// WithParent returns a fresh copy of n, with one parent added
|
||||
func (n Node) WithParent(key, parent string) Node {
|
||||
n.Parents = n.Parents.AddString(key, parent)
|
||||
return n
|
||||
}
|
||||
|
||||
// WithParents returns a fresh copy of n, with sets merged in.
|
||||
func (n Node) WithParents(parents Sets) Node {
|
||||
n.Parents = n.Parents.Merge(parents)
|
||||
|
||||
Reference in New Issue
Block a user