Merge pull request #313 from weaveworks/266-smarter-merge-take2

Neater implementation of de-duplication in MakeIDList()
This commit is contained in:
Tom Wilkie
2015-07-08 13:50:13 +01:00

View File

@@ -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)
}