Neater implementation of de-duplication in MakeIDList()

This commit is contained in:
Bryan Boreham
2015-07-07 22:15:07 +01:00
parent 0f76661bf6
commit 1fa853befe

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