# HG changeset patch # User Ted Unangst # Date 1728507726 14400 # Wed Oct 09 17:02:06 2024 -0400 # Node ID d8bb261c6432ae9131eb81a1ad8df9d052e46aca # Parent d652b081516c41e6086c029a3704bf60207005e0 can eliminate one cache diff --git a/fun.go b/fun.go --- a/fun.go +++ b/fun.go @@ -578,23 +578,6 @@ return s } -var shortnames = gencache.New(gencache.Options[UserID, map[string]string]{Fill: func(userid UserID) (map[string]string, bool) { - honkers := gethonkers(userid) - m := make(map[string]string) - for _, h := range honkers { - m[h.XID] = h.Name - } - return m, true -}, Invalidator: &honkerinvalidator}) - -func shortname(userid UserID, xid string) string { - m, ok := shortnames.Get(userid) - if ok { - return m[xid] - } - return "" -} - var honkerdirectory = gencache.New(gencache.Options[UserID, map[string]*Honker]{Fill: func(userid UserID) (map[string]*Honker, bool) { honkers := gethonkers(userid) m := make(map[string]*Honker) @@ -611,6 +594,12 @@ } return nil } +func shortname(userid UserID, xid string) string { + if h := gethonker(userid, xid); h != nil { + return h.Name + } + return "" +} var fullnames = gencache.New(gencache.Options[UserID, map[string]string]{Fill: func(userid UserID) (map[string]string, bool) { honkers := gethonkers(userid)