mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Merge pull request #313 from weaveworks/266-smarter-merge-take2
Neater implementation of de-duplication in MakeIDList()
This commit is contained in:
@@ -8,11 +8,12 @@ type IDList []string
|
||||
// MakeIDList makes a new IDList.
|
||||
func MakeIDList(ids ...string) IDList {
|
||||
sort.Strings(ids)
|
||||
for i := 1; i < len(ids); i++ { // shuffle down any duplicates
|
||||
for i := 1; i < len(ids); { // shuffle down any duplicates
|
||||
if ids[i-1] == ids[i] {
|
||||
ids = append(ids[:i-1], ids[i:]...)
|
||||
i--
|
||||
continue
|
||||
}
|
||||
i++
|
||||
}
|
||||
return IDList(ids)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user