prefetch handle info instead of waiting for load
Ted Unangst tedu@tedunangst.com
Sun, 18 Aug 2019 18:32:44 -0400
2 files changed,
13 insertions(+),
0 deletions(-)
M
activity.go
→
activity.go
@@ -252,6 +252,8 @@ whofore := 0
if strings.Contains(aud, user.URL) { whofore = 1 } + go prehandle(x.Honker) + go prehandle(x.Oonker) res, err := stmtSaveHonk.Exec(x.UserID, x.What, x.Honker, x.XID, x.RID, dt, x.URL, aud, x.Noise, x.Convoy, whofore, "html", x.Precis, x.Oonker, 0) if err != nil {
M
fun.go
→
fun.go
@@ -376,6 +376,9 @@ var handlelock sync.Mutex
// handle, handle@host func handles(xid string) (string, string) { + if xid == "" { + return "", "" + } handlelock.Lock() handle := allhandles[xid] handlelock.Unlock()@@ -413,6 +416,14 @@ log.Printf("error saving handle: %s", err)
} } return handle +} + +var handleprelock sync.Mutex + +func prehandle(xid string) { + handleprelock.Lock() + defer handleprelock.Unlock() + handles(xid) } func prepend(s string, x []string) []string {