diff options
author | João Abecasis <joao@abecasis.name> | 2009-07-16 18:48:39 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-07-22 12:36:14 (GMT) |
commit | 5f18fa27a6e87ee7cd568388cdf59cf85a3620e5 (patch) | |
tree | b741a5225d332f9519e5c14a3acf5bc0f8cd51e4 /src/corelib/io | |
parent | e316b2249f329b4754b23d9cc8c418c3645dc6db (diff) | |
download | Qt-5f18fa27a6e87ee7cd568388cdf59cf85a3620e5.zip Qt-5f18fa27a6e87ee7cd568388cdf59cf85a3620e5.tar.gz Qt-5f18fa27a6e87ee7cd568388cdf59cf85a3620e5.tar.bz2 |
QDirIterator moving around conditions
Which is faster QFileInfo::isSymlink() or QFileInfo::fileName() followed by
string comparisons?
Reviewed-by: Marius Storm-Olsen
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdiriterator.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index eae1dfa..6d6542f 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -235,15 +235,14 @@ bool QDirIteratorPrivate::shouldFollowDirectory(const QFileInfo &fileInfo) if (!fileInfo.isDir()) return false; - // Never follow . and .. - if (fileInfo.fileName() == QLatin1String(".") || fileInfo.fileName() == QLatin1String("..")) + // Follow symlinks only when asked + if (!(iteratorFlags & QDirIterator::FollowSymlinks) && fileInfo.isSymLink()) return false; - // Check symlinks - if (!(iteratorFlags & QDirIterator::FollowSymlinks) && fileInfo.isSymLink()) { - // Follow symlinks only if FollowSymlinks was passed + // Never follow . and .. + QString fileName = fileInfo.fileName(); + if (QLatin1String(".") == fileName || QLatin1String("..") == fileName) return false; - } // Stop link loops if (visitedLinks.contains(fileInfo.canonicalFilePath())) |