From 293479a1f24e13a8d3d5fe78fbcfba3da6566139 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Mon, 14 Feb 2022 11:47:29 +0300 Subject: [PATCH] Improve performance of checking path extension --- src/base/path.cpp | 4 +++- src/gui/uithememanager.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base/path.cpp b/src/base/path.cpp index 8f72c97ba..248fafb45 100644 --- a/src/base/path.cpp +++ b/src/base/path.cpp @@ -155,7 +155,9 @@ QString Path::extension() const bool Path::hasExtension(const QString &ext) const { - return (extension().compare(ext, Qt::CaseInsensitive) == 0); + Q_ASSERT(ext.startsWith(QLatin1Char('.'))); + + return m_pathStr.endsWith(ext, Qt::CaseInsensitive); } bool Path::hasAncestor(const Path &other) const diff --git a/src/gui/uithememanager.cpp b/src/gui/uithememanager.cpp index 295c92d97..4f033b63f 100644 --- a/src/gui/uithememanager.cpp +++ b/src/gui/uithememanager.cpp @@ -141,7 +141,7 @@ namespace if (themePath.filename() == CONFIG_FILE_NAME) return std::make_unique(themePath); - if ((themePath.extension() == QLatin1String(".qbtheme")) + if ((themePath.hasExtension(QLatin1String(".qbtheme"))) && QResource::registerResource(themePath.data(), QLatin1String("/uitheme"))) { return std::make_unique();