QDirListing: optimize recursive iteration
By moving the "isDir" check to the end of checkAndPushDirectory(). The other checks could be done without calling stat(), depending on the implementation. E.g. readdir on Linux (and BSD) fills the d_type field in `struct dirent`, so we know if it's a symlink without stat'ing, but to know if it's a symlink to a dir, we'll have to stat. Thanks to Thiago for pointing this out in code review. Change-Id: Iad9e954413afddfd4eb4890fb475655cda668385 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 104f8b23f236b1abd840eeaa4b82f54412d8a3b5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4a501bb51c
commit
892f75d430
@ -370,10 +370,6 @@ void QDirListingPrivate::checkAndPushDirectory(QDirEntryInfo &entryInfo)
|
||||
if (!iteratorFlags.testAnyFlags(F::Recursive))
|
||||
return;
|
||||
|
||||
// Never follow non-directory entries
|
||||
if (!entryInfo.isDir())
|
||||
return;
|
||||
|
||||
// Follow symlinks only when asked
|
||||
if (!iteratorFlags.testAnyFlags(F::FollowDirSymlinks) && entryInfo.isSymLink())
|
||||
return;
|
||||
@ -391,6 +387,10 @@ void QDirListingPrivate::checkAndPushDirectory(QDirEntryInfo &entryInfo)
|
||||
if (!includeHidden && entryInfo.isHidden())
|
||||
return;
|
||||
|
||||
// Never follow non-directory entries
|
||||
if (!entryInfo.isDir())
|
||||
return;
|
||||
|
||||
pushDirectory(entryInfo);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user