forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -342,7 +342,7 @@ QStringView FilePath::host() const
|
|||||||
|
|
||||||
QStringView FilePath::pathView() const
|
QStringView FilePath::pathView() const
|
||||||
{
|
{
|
||||||
return m_data.left(m_pathLen);
|
return QStringView(m_data).first(m_pathLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FilePath::path() const
|
QString FilePath::path() const
|
||||||
@@ -869,8 +869,7 @@ QVariant FilePath::toVariant() const
|
|||||||
|
|
||||||
bool FilePath::operator==(const FilePath &other) const
|
bool FilePath::operator==(const FilePath &other) const
|
||||||
{
|
{
|
||||||
return QString::compare(path(), other.path(), caseSensitivity()) == 0
|
return pathView().compare(other.pathView(), caseSensitivity()) == 0 && host() == other.host()
|
||||||
&& host() == other.host()
|
|
||||||
&& scheme() == other.scheme();
|
&& scheme() == other.scheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -881,7 +880,7 @@ bool FilePath::operator!=(const FilePath &other) const
|
|||||||
|
|
||||||
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)
|
if (cmp != 0)
|
||||||
return cmp < 0;
|
return cmp < 0;
|
||||||
if (host() != other.host())
|
if (host() != other.host())
|
||||||
|
Reference in New Issue
Block a user