From 615e3e55fc56a5f5378db404cd89a443e7e74e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 16 Jul 2009 19:17:45 +0200 Subject: QDirIterator: another one bites the dust Removing another data member in QDirIteratorPrivate. The only reason I see for not doing this is to delay doing work as much as possible. Since copy constructors are disabled anyway, once QDirIterator is instantiated one has already signed up for the pain. The code also looks cleaner this way. Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qdiriterator.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 5f37bd7..51bb98a 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -121,7 +121,6 @@ public: QDirIterator::IteratorFlags iteratorFlags; QDir::Filters filters; QStringList nameFilters; - bool followNextDir; bool first; bool done; @@ -135,7 +134,7 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList QDir::Filters filters, QDirIterator::IteratorFlags flags) : engine(0), path(path), iteratorFlags(flags), filters(filters), nameFilters(nameFilters), - followNextDir(false), first(true), done(false) + first(true), done(false) { if (QDir::NoFilter == filters) this->filters = QDir::AllEntries; @@ -183,14 +182,6 @@ void QDirIteratorPrivate::pushSubDirectory(const QFileInfo &fileInfo) */ void QDirIteratorPrivate::advance() { - // Advance to the next entry - if (followNextDir) { - // Start by navigating into the current directory. - QAbstractFileEngineIterator *it = fileEngineIterators.top(); - pushSubDirectory(it->currentFileInfo()); - followNextDir = false; - } - while (!fileEngineIterators.isEmpty()) { QAbstractFileEngineIterator *it = fileEngineIterators.top(); @@ -202,8 +193,10 @@ void QDirIteratorPrivate::advance() if (matchesFilters(it->currentFileName(), info)) { currentFileInfo = nextFileInfo; nextFileInfo = info; - // Signal that we want to follow this entry. - followNextDir = shouldFollowDirectory(nextFileInfo); + + if(shouldFollowDirectory(nextFileInfo)) + pushSubDirectory(nextFileInfo); + //We found a matching entry. return; -- cgit v0.12