QDir: when sorting use the cached filename if it was assigned to

After commit b5a54d488c, we now use QCollator and so no toLower()
when caching the filename, we can re-use it from the cache after
sorting.

Change-Id: I8602a11c6f68cfe61db3ec6330596066cd257dab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2023-02-14 21:49:13 +02:00
parent 4f1d3426ac
commit b9b7f44563

View File

@ -330,13 +330,17 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, const QFileInfoList
// put them back in the list(s)
for (qsizetype i = 0; i < n; ++i) {
auto &fileInfo = si[i].item;
if (infos)
infos->append(si[i].item);
if (names)
names->append(si[i].item.fileName());
infos->append(fileInfo);
if (names) {
const bool cached = !si[i].filename_cache.isNull();
names->append(cached ? si[i].filename_cache : fileInfo.fileName());
}
}
}
}
inline void QDirPrivate::initFileLists(const QDir &dir) const
{
QMutexLocker locker(&fileCache.mutex);