summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-07-17 13:31:41 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-07-22 12:36:16 (GMT)
commit0ba33d83108f21abbd98cde1accdbba5bce625d2 (patch)
tree3cd58e3f9a3eb176d89d9757ac50fba208319826
parentf2dce82831706a38cd97225edb2edc0ed2a1520e (diff)
downloadQt-0ba33d83108f21abbd98cde1accdbba5bce625d2.zip
Qt-0ba33d83108f21abbd98cde1accdbba5bce625d2.tar.gz
Qt-0ba33d83108f21abbd98cde1accdbba5bce625d2.tar.bz2
QDirIterator: no point in delaying the inevitable
The only reason I see for not calling advance() directly in the constructor is to delay potentially unnecessary work. However, since copy constructors have been explicitly disabled, once QDirIterator is instantiated one has signed up for all the pain that comes with it. That's also a couple less conditionals in each iteration of normal use cases. Reviewed-by: Marius Storm-Olsen
-rw-r--r--src/corelib/io/qdiriterator.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 0ea7097..0e4d563 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 first;
QDirIterator *q;
};
@@ -132,13 +131,14 @@ public:
QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList &nameFilters,
QDir::Filters filters, QDirIterator::IteratorFlags flags)
: engine(0), path(path), iteratorFlags(flags),
- filters(filters), nameFilters(nameFilters),
- first(true)
+ filters(filters), nameFilters(nameFilters)
{
if (QDir::NoFilter == filters)
this->filters = QDir::AllEntries;
+ // Populate fields for hasNext() and next()
pushSubDirectory(QFileInfo(path));
+ advance();
}
/*!
@@ -459,10 +459,6 @@ QString QDirIterator::next()
*/
bool QDirIterator::hasNext() const
{
- if (d->first) {
- d->first = false;
- d->advance();
- }
return !d->fileEngineIterators.isEmpty();
}