mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-19 23:57:15 +00:00
Add method to add a single string into Sets
This avoids creating and discarding a StringSet just to pass the parameter
This commit is contained in:
@@ -46,6 +46,21 @@ func (s Sets) Add(key string, value StringSet) Sets {
|
||||
}
|
||||
}
|
||||
|
||||
// AddString adds a single string under a key, creating a new StringSet if necessary.
|
||||
func (s Sets) AddString(key string, str string) Sets {
|
||||
if s.psMap == nil {
|
||||
s = emptySets
|
||||
}
|
||||
value, found := s.Lookup(key)
|
||||
if found && value.Contains(str) {
|
||||
return s
|
||||
}
|
||||
value = value.Add(str)
|
||||
return Sets{
|
||||
psMap: s.psMap.Set(key, value),
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the given set from the Sets.
|
||||
func (s Sets) Delete(key string) Sets {
|
||||
if s.psMap == nil {
|
||||
|
||||
Reference in New Issue
Block a user