tighter loop

This commit is contained in:
Ted Unangst 2019-06-01 16:11:04 -04:00
parent e7a770bac2
commit ce850eb0cb
1 changed files with 7 additions and 16 deletions

19
fun.go
View File

@ -79,28 +79,19 @@ func reverbolate(honks []*Honk) {
func osmosis(honks []*Honk, userid int64) []*Honk {
zwords := getzwords(userid)
collapse := false
for i, h := range honks {
j := 0
outer:
for _, h := range honks {
for _, z := range zwords {
if z.MatchString(h.Precis) || z.MatchString(h.Noise) {
honks[i] = nil
collapse = true
break
continue outer
}
}
}
if collapse {
j := 0
for i := 0; i < len(honks); i++ {
if honks[i] != nil {
honks[j] = honks[i]
honks[j] = h
j++
}
}
return honks[0:j]
}
return honks
}
func shortxid(xid string) string {
idx := strings.LastIndexByte(xid, '/')