From 660e690195919cf657bc2177f7ec03134fc36e56 Mon Sep 17 00:00:00 2001 From: scorpion-26 <58082714+scorpion-26@users.noreply.github.com> Date: Fri, 3 Mar 2023 17:02:59 +0100 Subject: [PATCH] Cache SetText Apparently, gtk_button_set_label is very expensive to do. Now it is only called when necessary. This is the culprit for the mysterious high CPU usage and not the Hyprland IPC as said in https://github.com/scorpion-26/gBar/issues/7 and https://github.com/scorpion-26/gBar/issues/8. --- src/Widget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Widget.cpp b/src/Widget.cpp index d05ee63..f645d78 100644 --- a/src/Widget.cpp +++ b/src/Widget.cpp @@ -524,11 +524,11 @@ void Button::Create() void Button::SetText(const std::string& text) { - m_Text = text; - if (m_Widget) + if (m_Widget && text != m_Text) { gtk_button_set_label((GtkButton*)m_Widget, m_Text.c_str()); } + m_Text = text; } void Button::OnClick(Callback