diff options
author | João Abecasis <joao@abecasis.name> | 2009-07-22 10:49:01 (GMT) |
---|---|---|
committer | João Abecasis <joao@abecasis.name> | 2009-07-22 12:36:17 (GMT) |
commit | 8aaf775d3746529e8efa5110673a274ac6a7f8d4 (patch) | |
tree | 391b2d7f45596c65f42b95393bd7b3319c7526b8 /src | |
parent | eabc4109a2703aa761eff7a26cfa7001af8577a3 (diff) | |
download | Qt-8aaf775d3746529e8efa5110673a274ac6a7f8d4.zip Qt-8aaf775d3746529e8efa5110673a274ac6a7f8d4.tar.gz Qt-8aaf775d3746529e8efa5110673a274ac6a7f8d4.tar.bz2 |
QDirIterator refactoring
'*' is functionally the same as having no name filters. Equating the
equivalence in the constructor avoids repeated checks in the advance
"loop".
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src')
-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 371e822..f7df836 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -136,7 +136,7 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList QDir::Filters filters, QDirIterator::IteratorFlags flags) : engine(QAbstractFileEngine::create(path)) , path(path) - , nameFilters(nameFilters) + , nameFilters(nameFilters.contains(QLatin1String("*")) ? QStringList() : nameFilters) , filters(QDir::NoFilter == filters ? QDir::AllEntries : filters) , iteratorFlags(flags) { @@ -270,10 +270,9 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf return false; // name filter -#ifndef QT_NO_REGEXP - const bool hasNameFilters = !nameFilters.isEmpty() && !(nameFilters.contains(QLatin1String("*"))); +#ifndef QT_NO_REGEXP // Pass all entries through name filters, except dirs if the AllDirs - if (hasNameFilters && !((filters & QDir::AllDirs) && fi.isDir())) { + if (!nameFilters.isEmpty() && !((filters & QDir::AllDirs) && fi.isDir())) { bool matched = false; for (int i = 0; i < nameFilters.size(); ++i) { QRegExp regexp(nameFilters.at(i), @@ -377,7 +376,7 @@ QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags) \sa hasNext(), next(), IteratorFlags */ QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags) - : d(new QDirIteratorPrivate(path, QStringList(QLatin1String("*")), filters, flags)) + : d(new QDirIteratorPrivate(path, QStringList(), filters, flags)) { d->q = this; } @@ -395,7 +394,7 @@ QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorF \sa hasNext(), next(), IteratorFlags */ QDirIterator::QDirIterator(const QString &path, IteratorFlags flags) - : d(new QDirIteratorPrivate(path, QStringList(QLatin1String("*")), QDir::NoFilter, flags)) + : d(new QDirIteratorPrivate(path, QStringList(), QDir::NoFilter, flags)) { d->q = this; } |