From c84d12227d49d84922448cbd217efd920af6d8dd Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 17 Nov 2022 16:08:04 +0100 Subject: [PATCH] FilePath: Fix pathView() and use at more places pathView was constructing a QStringView on a temporary, which silently does weird stuff. After the change to a single-string representation, the QString construction for path() is expansive for the comparison operators. Change-Id: I543c7115d3ad52f971d1692230b6eab82645b810 Reviewed-by: hjk --- src/libs/utils/filepath.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/utils/filepath.cpp b/src/libs/utils/filepath.cpp index 8e47d2ab3fc..f17f0f0f73a 100644 --- a/src/libs/utils/filepath.cpp +++ b/src/libs/utils/filepath.cpp @@ -342,7 +342,7 @@ QStringView FilePath::host() const QStringView FilePath::pathView() const { - return m_data.left(m_pathLen); + return QStringView(m_data).first(m_pathLen); } QString FilePath::path() const @@ -869,9 +869,8 @@ QVariant FilePath::toVariant() const bool FilePath::operator==(const FilePath &other) const { - return QString::compare(path(), other.path(), caseSensitivity()) == 0 - && host() == other.host() - && scheme() == other.scheme(); + return pathView().compare(other.pathView(), caseSensitivity()) == 0 && host() == other.host() + && scheme() == other.scheme(); } bool FilePath::operator!=(const FilePath &other) const @@ -881,7 +880,7 @@ bool FilePath::operator!=(const FilePath &other) const bool FilePath::operator<(const FilePath &other) const { - const int cmp = QString::compare(path(), other.path(), caseSensitivity()); + const int cmp = pathView().compare(other.pathView(), caseSensitivity()); if (cmp != 0) return cmp < 0; if (host() != other.host())