all repos — honk @ 0ae8e6b5478a64f6888591267a5c3f7797a4891a

my fork of honk

tighter loop
Ted Unangst tedu@tedunangst.com
Sat, 01 Jun 2019 16:11:04 -0400
commit

0ae8e6b5478a64f6888591267a5c3f7797a4891a

parent

48a2c70ffc89605ed78ca836fe6abab31470f9b1

1 files changed, 7 insertions(+), 16 deletions(-)

jump to
M fun.gofun.go

@@ -79,27 +79,18 @@ }

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 {