diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-02-14 21:49:13 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-02-17 10:36:05 +0200 |
commit | b9b7f44563316af3fbd93d18d11964f68243dd05 (patch) | |
tree | b211ae70c736b5dea0171204223d67a78dacca53 | |
parent | 4f1d3426acbb080d52941b3e2a44a9cf91c5573a (diff) |
QDir: when sorting use the cached filename if it was assigned to
After commit b5a54d488cfc94a3, 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>
-rw-r--r-- | src/corelib/io/qdir.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index f55cf6b5f9..d560f67c0e 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -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); |