From 7ea1d5247b23874bb549e0a444a1e5aa9102348a Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Thu, 17 Aug 2023 12:37:32 +0500 Subject: [PATCH] UI: IconCache: Microoptimize file() --- src/ui/util/iconcache.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ui/util/iconcache.cpp b/src/ui/util/iconcache.cpp index df346942..c4c00d91 100644 --- a/src/ui/util/iconcache.cpp +++ b/src/ui/util/iconcache.cpp @@ -51,21 +51,22 @@ QPixmap IconCache::file(const QString &filePath) { checkThread(); - QString adjustedFilePath = filePath; - - // Try to use "./icons/" folder from current working dir. - if (filePath.startsWith(':')) { - adjustedFilePath[0] = '.'; - - if (!FileUtil::fileExists(adjustedFilePath)) { - adjustedFilePath = filePath; - } - } - QPixmap pixmap; - if (!find(adjustedFilePath, &pixmap)) { + if (!find(filePath, &pixmap)) { + QString adjustedFilePath = filePath; + + // Try to use "./icons/" folder from current working dir. + if (filePath.startsWith(':')) { + adjustedFilePath[0] = '.'; + + if (!FileUtil::fileExists(adjustedFilePath)) { + adjustedFilePath = filePath; + } + } + pixmap.load(adjustedFilePath); - insert(adjustedFilePath, pixmap); + + insert(filePath, pixmap); } return pixmap; }