prefetch handle info instead of waiting for load

master
Ted Unangst 5 years ago
parent 877b0e043b
commit 27b5bc5f5f

@ -252,6 +252,8 @@ func savexonk(user *WhatAbout, x *Honk) {
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 {

@ -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()
@ -415,6 +418,14 @@ func findhandle(xid string) string {
return handle
}
var handleprelock sync.Mutex
func prehandle(xid string) {
handleprelock.Lock()
defer handleprelock.Unlock()
handles(xid)
}
func prepend(s string, x []string) []string {
return append([]string{s}, x...)
}

Loading…
Cancel
Save