From 4240f1fbfd095724bcbb0ea49cfa561c973ba6ce Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 3 Jul 2022 10:11:13 -0500 Subject: 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 Acked-by: Robin Jarry --- config/config.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'config/config.go') diff --git a/config/config.go b/config/config.go index ee8dc6a..8a243c3 100644 --- a/config/config.go +++ b/config/config.go @@ -1027,6 +1027,10 @@ func (config AercConfig) GetUiConfig(params map[ContextType]string) *UIConfig { return &baseUi } +func (config *AercConfig) GetContextualUIConfigs() []UIConfigContext { + return config.ContextualUis +} + func (uiConfig UIConfig) GetStyle(so StyleObject) tcell.Style { return uiConfig.style.Get(so) } -- cgit v1.2.3