From ce850eb0cb6bd0ef4744cf757489a340550bbc29 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 1 Jun 2019 16:11:04 -0400 Subject: [PATCH] tighter loop --- fun.go | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/fun.go b/fun.go index 766c795..7cfa67e 100644 --- a/fun.go +++ b/fun.go @@ -79,27 +79,18 @@ 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 } } + honks[j] = h + j++ } - if collapse { - j := 0 - for i := 0; i < len(honks); i++ { - if honks[i] != nil { - honks[j] = honks[i] - j++ - } - } - return honks[0:j] - } - return honks + return honks[0:j] } func shortxid(xid string) string {