all repos — honk @ 07821ff8e0c3a0c5b907424c404b2993982f80cc

my fork of honk

order some filtering loops better to avoid repeated lookups
Ted Unangst tedu@tedunangst.com
Mon, 23 Dec 2019 06:13:07 -0500
commit

07821ff8e0c3a0c5b907424c404b2993982f80cc

parent

7930957a26e97dae2483e576855657669c6c3b86

2 files changed, 42 insertions(+), 29 deletions(-)

jump to
M fun.gofun.go

@@ -104,24 +104,24 @@ n, _ := htf.String(h.Noise)

h.Precis = string(p) h.Noise = string(n) } - - if userid == -1 { - if h.Precis != "" { - h.Open = "" - } - } else { - unsee(userid, h) - if h.Open == "open" && h.Precis == "unspecified horror" { - h.Precis = "" - } - } - if len(h.Noise) > 6000 && h.Open == "open" { - if h.Precis == "" { - h.Precis = "really freaking long" + j := 0 + for i := 0; i < len(h.Donks); i++ { + if !zap[h.Donks[i].XID] { + h.Donks[j] = h.Donks[i] + j++ } - h.Open = "" } + h.Donks = h.Donks[:j] + } + unsee(honks, userid) + + for _, h := range honks { + local := false + if h.Whofore == 2 || h.Whofore == 3 { + local = true + } + zap := make(map[string]bool) emuxifier := func(e string) string { for _, d := range h.Donks { if d.Name == e {
M hfcs.gohfcs.go

@@ -353,21 +353,34 @@ }

return false } -func unsee(userid int64, h *Honk) { - filts := getfilters(userid, filtCollapse) - for _, f := range filts { - if bad := matchfilterX(h, f); bad != "" { - if h.Precis == "" { - h.Precis = bad +func unsee(honks []*Honk, userid int64) { + if userid != -1 { + colfilts := getfilters(userid, filtCollapse) + rwfilts := getfilters(userid, filtRewrite) + for _, h := range honks { + for _, f := range colfilts { + if bad := matchfilterX(h, f); bad != "" { + if h.Precis == "" { + h.Precis = bad + } + h.Open = "" + break + } + } + if h.Open == "open" && h.Precis == "unspecified horror" { + h.Precis = "" + } + for _, f := range rwfilts { + if matchfilter(h, f) { + h.Noise = f.re_rewrite.ReplaceAllString(h.Noise, f.Replace) + } } - h.Open = "" - break - } - } - filts = getfilters(userid, filtRewrite) - for _, f := range filts { - if matchfilter(h, f) { - h.Noise = f.re_rewrite.ReplaceAllString(h.Noise, f.Replace) + if len(h.Noise) > 6000 && h.Open == "open" { + if h.Precis == "" { + h.Precis = "really freaking long" + } + h.Open = "" + } } } }