From c5cefb5520d249d0c0b1188186a0c7db32be0506 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 3 Jul 2026 22:10:16 +0200 Subject: [PATCH] AIconLabel: make regex static and initialize label_contains_icon Compile the icon-extraction std::regex objects once via static locals instead of rebuilding them on every update() of every AIconLabel-derived module (custom, mpris, ...). Also default-initialize label_contains_icon to false at its declaration. --- include/AIconLabel.hpp | 2 +- src/AIconLabel.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/AIconLabel.hpp b/include/AIconLabel.hpp index 1fac814c..80aa431a 100644 --- a/include/AIconLabel.hpp +++ b/include/AIconLabel.hpp @@ -21,7 +21,7 @@ class AIconLabel : public ALabel { Gtk::Box box_; unsigned app_icon_size_{24}; - bool label_contains_icon; + bool label_contains_icon{false}; bool iconEnabled() const; }; diff --git a/src/AIconLabel.cpp b/src/AIconLabel.cpp index 9cadcf39..c17eb8d4 100644 --- a/src/AIconLabel.cpp +++ b/src/AIconLabel.cpp @@ -65,12 +65,12 @@ std::tuple AIconLabel::extractIcon(const std::string& std::string icon_result = ""; std::string label_result = input; try { - const std::regex icon_search(R"((?=\\0icon\\1f).+?(?=\\n))"); + static const std::regex icon_search(R"((?=\\0icon\\1f).+?(?=\\n))"); std::smatch icon_match; if (std::regex_search(input, icon_match, icon_search)) { icon_result = icon_match[0].str().substr(9); - - const std::regex clean_label_pattern(R"(\\0icon\\1f.+?\\n)"); + + static const std::regex clean_label_pattern(R"(\\0icon\\1f.+?\\n)"); label_result = std::regex_replace(input, clean_label_pattern, ""); } } catch (const std::exception& e) {