summaryrefslogtreecommitdiff
path: root/widgets/account.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-07-03 10:11:13 -0500
committerRobin Jarry <robin@jarry.cc>2022-07-03 21:32:24 +0200
commit4240f1fbfd095724bcbb0ea49cfa561c973ba6ce (patch)
treedbece5561d81a56eb106d0f6fe2019fb6d41e9c9 /widgets/account.go
parentd45c07eb6a0955a24efec7bd915ba19746042778 (diff)
downloadaerc-4240f1fbfd095724bcbb0ea49cfa561c973ba6ce.zip
perf: reduce calls to GetUiConfig
GetUiConfig was being called many times, and came up as a high CPU user in a cpuprofile. Every call would merge a UIConfig, which is a costly operation. Ideally, we would only need to have a config for every account X every directory. We also have a context for subjects. This patch stores all FOLDER and ACCOUNT level configs and reuses those merged objects. The SUBJECT contexts are not stored in favor of merging on-the-go, with a TODO comment to deprecate that feature and implement a better per-message styling option. I suspect this feature is not used very much. Before applying this patch with my setup, GetUiConfig is called 1159 times just to open aerc. After applying, this is reduced to 37. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 725090e..55e76be 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -34,17 +34,14 @@ type AccountView struct {
worker *types.Worker
state *statusline.State
newConn bool // True if this is a first run after a new connection/reconnection
+ uiConf *config.UIConfig
}
func (acct *AccountView) UiConfig() *config.UIConfig {
- var folder string
if dirlist := acct.Directories(); dirlist != nil {
- folder = dirlist.Selected()
+ return dirlist.UiConfig()
}
- return acct.conf.GetUiConfig(map[config.ContextType]string{
- config.UI_CONTEXT_ACCOUNT: acct.AccountConfig().Name,
- config.UI_CONTEXT_FOLDER: folder,
- })
+ return acct.uiConf
}
func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountConfig,
@@ -61,6 +58,7 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon
host: host,
logger: logger,
state: statusline.NewState(acct.Name, len(conf.Accounts) > 1, conf.Statusline),
+ uiConf: acctUiConf,
}
view.grid = ui.NewGrid().Rows([]ui.GridSpec{