From e88a8bd627e354980304b718e71df26c10715a07 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 27 May 2024 20:08:38 +0300 Subject: [PATCH] kio: do not cache the name in lower case from KFileItem::name() case-insensitive comparison is faster and is already done by KDirSortFilterProxyModel Signed-off-by: Ivailo Monev --- kio/kfile/kdirsortfilterproxymodel.cpp | 4 +--- kio/kio/kfileitem.cpp | 15 ++------------- kio/kio/kfileitem.h | 4 +--- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/kio/kfile/kdirsortfilterproxymodel.cpp b/kio/kfile/kdirsortfilterproxymodel.cpp index c83f72c0..b752c1ef 100644 --- a/kio/kfile/kdirsortfilterproxymodel.cpp +++ b/kio/kfile/kdirsortfilterproxymodel.cpp @@ -171,9 +171,7 @@ bool KDirSortFilterProxyModel::subSortLessThan(const QModelIndex& left, int result = d->compare(leftFileItem.text(), rightFileItem.text(), sortCaseSensitivity()); if (result == 0) { // KFileItem::text() may not be unique in case UDS_DISPLAY_NAME is used - result = d->compare(leftFileItem.name(sortCaseSensitivity() == Qt::CaseInsensitive), - rightFileItem.name(sortCaseSensitivity() == Qt::CaseInsensitive), - sortCaseSensitivity()); + result = d->compare(leftFileItem.name(), rightFileItem.name(), sortCaseSensitivity()); if (result == 0) { // If KFileItem::text() is also not unique most probably a search protocol is used // that allows showing the same file names from different directories diff --git a/kio/kio/kfileitem.cpp b/kio/kio/kfileitem.cpp index 485fa4e1..678f5e85 100644 --- a/kio/kio/kfileitem.cpp +++ b/kio/kio/kfileitem.cpp @@ -155,11 +155,6 @@ public: */ mutable QString m_iconName; - /** - * The filename in lower case (to speed up sorting) - */ - mutable QString m_strLowerCaseName; - /** * The mimetype of the file */ @@ -1081,18 +1076,12 @@ QString KFileItem::text() const return d->m_strText; } -QString KFileItem::name(bool lowerCase) const +QString KFileItem::name() const { if (!d) { return QString(); } - if (!lowerCase) { - return d->m_strName; - } - if (d->m_strLowerCaseName.isNull()) { - d->m_strLowerCaseName = d->m_strName.toLower(); - } - return d->m_strLowerCaseName; + return d->m_strName; } KUrl KFileItem::targetUrl() const diff --git a/kio/kio/kfileitem.h b/kio/kio/kfileitem.h index 658d5678..ea1863d3 100644 --- a/kio/kio/kfileitem.h +++ b/kio/kio/kfileitem.h @@ -282,11 +282,9 @@ public: /** * Return the name of the file item (without a path). * Similar to text(), but unencoded, i.e. the original name. - * @param lowerCase if true, the name will be returned in lower case, - * which is useful to speed up sorting by name, case insensitively. * @return the file's name */ - QString name(bool lowerCase = false) const; + QString name() const; /** * Returns the mimetype of the file item. Equivalent to mimeTypePtr()->name()