From 27b5bc5f5f7111ea9bf050770e783bac9b7db0b0 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 18 Aug 2019 18:32:44 -0400 Subject: [PATCH] prefetch handle info instead of waiting for load --- activity.go | 2 ++ fun.go | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/activity.go b/activity.go index 27a69be..5e78837 100644 --- a/activity.go +++ b/activity.go @@ -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 { diff --git a/fun.go b/fun.go index 972a159..a891aca 100644 --- a/fun.go +++ b/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() @@ -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...) }