aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-03-19 13:30:07 +0100
committerRobin Jarry <robin@jarry.cc>2022-03-20 09:58:09 +0100
commite49f08e35fa7d7439de1df7f362c69ed188358dc (patch)
tree275b63daf0c097cd1c9c1a8cf02d6f632a53a35e
parent2512c0403fa42b19c3e87fed44240da045ec902f (diff)
downloadaerc-e49f08e35fa7d7439de1df7f362c69ed188358dc.tar.gz
statusline: update status only when necessary
Update statusline only when changed to reduce cpu usage. commit 2512c0403fa4 ("statusline: implement per-account status") updates the status irrespective of whether the statusline changed or not. This can lead to high cpu usage that can be avoided. Reported-by: Jens Grassel <jens@wegtam.com> Reported-by: inwit <inwit@sindominio.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--widgets/account.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 647a3aee..5d1315c2 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -32,6 +32,7 @@ type AccountView struct {
msglist *MessageList
worker *types.Worker
state *statusline.State
+ update bool
}
func (acct *AccountView) UiConfig() config.UIConfig {
@@ -113,6 +114,7 @@ func (acct *AccountView) SetStatus(setters ...statusline.SetStateFunc) {
for _, fn := range setters {
fn(acct.state)
}
+ acct.update = true
}
func (acct *AccountView) UpdateStatus() {
@@ -158,7 +160,10 @@ func (acct *AccountView) Invalidate() {
}
func (acct *AccountView) Draw(ctx *ui.Context) {
- acct.UpdateStatus()
+ if acct.update {
+ acct.UpdateStatus()
+ acct.update = false
+ }
acct.grid.Draw(ctx)
}