From 8a100514ef2cd9486bb33b695c94fcfcf51708d7 Mon Sep 17 00:00:00 2001 From: Qoole <2862661+qoole@users.noreply.github.com> Date: Tue, 26 May 2026 20:20:19 +0100 Subject: [PATCH] perf(activity): inline FolderMan::instance() and avoid string concat in hot path - FolderMan::instance(): make it an inline accessor returning the static pointer, removing the out-of-line call overhead at every use site without adding any local caching or extra complexity. - ActivityListModel::convertLinkToActionButton: move the reply icon URL construction inside the isReplyIconApplicable branch and bake the trailing slash into the string literal so the path is a single immutable QString instead of two QString::operator+ allocations. Signed-off-by: Qoole <2862661+qoole@users.noreply.github.com> --- src/gui/folderman.cpp | 5 ----- src/gui/folderman.h | 2 +- src/gui/tray/activitylistmodel.cpp | 9 +++++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index ae388eb8d412a..0f4e76277afc9 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -97,11 +97,6 @@ FolderMan::FolderMan(QObject *parent) connect(this, &FolderMan::folderListChanged, this, &FolderMan::slotSetupPushNotifications); } -FolderMan *FolderMan::instance() -{ - return _instance; -} - FolderMan::~FolderMan() { qDeleteAll(_folderMap); diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 0b91633371010..65bc4a0886e13 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -80,7 +80,7 @@ class FolderMan : public QObject }; ~FolderMan() override; - static FolderMan *instance(); + static FolderMan *instance() { return _instance; } int setupFolders(); int setupFoldersMigration(); diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 20ece0431aeb6..7635634938b40 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -904,11 +904,12 @@ QVariant ActivityListModel::convertLinkToActionButton(const OCC::ActivityLink &a const auto isReplyIconApplicable = activityLink._verb == QStringLiteral("REPLY"); - const QString replyButtonPath = QStringLiteral("image://svgimage-custom-color/reply.svg"); - if (isReplyIconApplicable) { - activityLinkCopy._imageSource = QString(replyButtonPath + "/"); - activityLinkCopy._imageSourceHovered = QString(replyButtonPath + "/"); + using namespace Qt::StringLiterals; + + const auto replyButtonPath = u"image://svgimage-custom-color/reply.svg/"_s; + activityLinkCopy._imageSource = replyButtonPath; + activityLinkCopy._imageSourceHovered = replyButtonPath; } return QVariant::fromValue(activityLinkCopy);