rewrite oneofakind with map since we're starting to see longer arrays

This commit is contained in:
Ted Unangst 2019-10-19 15:37:33 -04:00
parent 3de799b34c
commit ec15e6041a
1 changed files with 9 additions and 10 deletions

19
fun.go
View File

@ -538,18 +538,17 @@ func firstclass(honk *Honk) bool {
} }
func oneofakind(a []string) []string { func oneofakind(a []string) []string {
var x []string seen := make(map[string]bool)
for n, s := range a { seen[""] = true
if s != "" { j := 0
x = append(x, s) for _, s := range a {
for i := n + 1; i < len(a); i++ { if !seen[s] {
if a[i] == s { seen[s] = true
a[i] = "" a[j] = s
} j++
}
} }
} }
return x return a[:j]
} }
var ziggies = make(map[string]*rsa.PrivateKey) var ziggies = make(map[string]*rsa.PrivateKey)