tighter loop
This commit is contained in:
parent
e7a770bac2
commit
ce850eb0cb
19
fun.go
19
fun.go
|
@ -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, '/')
|
||||
|
|
Loading…
Reference in New Issue