[network/ruqola] src/widgets/misc: Minor optimization. Avoid to recalculate 3 time toLocalFile()

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit b326300fce734d79f7415336235ca205ca5aacbf by Laurent Montel.
Committed on 13/08/2026 at 20:35.
Pushed by mlaurent into branch 'master'.

Minor optimization. Avoid to recalculate 3 time toLocalFile()

M  +7    -7    src/widgets/misc/avatarcachemanager.cpp

https://invent.kde.org/network/ruqola/-/commit/b326300fce734d79f7415336235ca205ca5aacbf

diff --git a/src/widgets/misc/avatarcachemanager.cpp b/src/widgets/misc/avatarcachemanager.cpp
index 943db4edda..e07e903b80 100644
--- a/src/widgets/misc/avatarcachemanager.cpp
+++ b/src/widgets/misc/avatarcachemanager.cpp
@@ -102,8 +102,8 @@ void AvatarCacheManager::setMaxEntries(int maxEntries)
 
 QPixmap AvatarCacheManager::makeAvatarUrlPixmap(const QWidget *widget, const QString &url, int maxHeight) const
 {
-    const QUrl iconUrlStr = mRocketChatAccount->previewUrlFromLocalCache(url);
-    if (iconUrlStr.isEmpty()) {
+    const QUrl iconUrl = mRocketChatAccount->previewUrlFromLocalCache(url);
+    if (iconUrl.isEmpty()) {
         return {};
     }
 
@@ -111,18 +111,18 @@ QPixmap AvatarCacheManager::makeAvatarUrlPixmap(const QWidget *widget, const QSt
 
     auto &cache = mAvatarCache.cache;
 
-    auto downScaled = cache.findCachedPixmap(iconUrlStr.toLocalFile());
+    auto downScaled = cache.findCachedPixmap(iconUrl.toLocalFile());
     if (downScaled.isNull()) {
-        const QUrl &iconUrl(iconUrlStr);
         Q_ASSERT(iconUrl.isLocalFile());
         QPixmap fullScale;
-        if (!fullScale.load(iconUrl.toLocalFile())) {
-            qCWarning(RUQOLAWIDGETS_LOG) << "Could not load" << iconUrl.toLocalFile();
+        const QString iconUrlLocalFile = iconUrl.toLocalFile();
+        if (!fullScale.load(iconUrlLocalFile)) {
+            qCWarning(RUQOLAWIDGETS_LOG) << "Could not load" << iconUrlLocalFile;
             return {};
         }
         downScaled = fullScale.scaledToHeight(maxHeight * dpr, Qt::SmoothTransformation);
         downScaled.setDevicePixelRatio(dpr);
-        cache.insertCachedPixmap(iconUrlStr.toLocalFile(), downScaled);
+        cache.insertCachedPixmap(iconUrlLocalFile, downScaled);
     }
     return downScaled;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.