diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-12-14 18:26:33 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2024-02-09 18:44:23 +0200 |
commit | 83f7125ac866ed5a2aaace56ffc866f21f9730b4 (patch) | |
tree | 516df9233f82076d678c11733b0d2520813f18a9 /src/corelib/io/qfilesystemiterator_win.cpp | |
parent | 74722411d3fbfcc30d8eff98efcc627be451aea9 (diff) |
QFileSystemIterator/Unix: use QStringDecoder
The end result is a QFileInfo constructed from the QFileSystemEntry;
QFileSystemEntry's API will at some point convert the NativePath (QBA on
Unix) to a QString, e.g. when it calls findLastSeparator().
So instead of converting the parent dir path from Utf8 to Utf16 multiple
times, store the dir path as a QString once in the constructor.
Use QStringDecoder to convert the dirent->d_name to Utf16 and check the
decoder's hasError(); which as Thiago pointed out, is more efficient
than using isValidUtf8(), throwing away the results, then converting to
unicode anyway later on in QDirIteratorPrivate::advance().
(Ironically) `QFileSystemEntry::NativePath nativePath` is still used on
Windows.
Change-Id: Icd2b130103640b502862d210d64926b99c499a01
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qfilesystemiterator_win.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemiterator_win.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 30c39f6b4d..7644a1a078 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -15,8 +15,8 @@ using namespace Qt::StringLiterals; bool done = true; QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters) - : nativePath(entry.nativeFilePath()) - , dirPath(entry.filePath()) + : dirPath(entry.filePath()) + , nativePath(entry.nativeFilePath()) , findFileHandle(INVALID_HANDLE_VALUE) , uncFallback(false) , uncShareIndex(0) |