summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Abecasis <joao@abecasis.name>2009-07-16 19:20:31 (GMT)
committerJoão Abecasis <joao@abecasis.name>2009-07-22 12:36:16 (GMT)
commita8aa2c7a7f40883680b7989465873554dfbba3d6 (patch)
tree849a87405efcc94f7c6547e9eba78e3ab51030ba
parent3d5b6f694f477a3529e79e72d66824b8befa0dc2 (diff)
downloadQt-a8aa2c7a7f40883680b7989465873554dfbba3d6.zip
Qt-a8aa2c7a7f40883680b7989465873554dfbba3d6.tar.gz
Qt-a8aa2c7a7f40883680b7989465873554dfbba3d6.tar.bz2
QDirIterator refactoring
Now that the heavy lifting has been done, we can condense QDirIteratorPrivate::advance() further. It almost looks nice, even! Using fileEngineIterators.top() directly in the loop condition allows us to manipulate the stack without the foundDirectory check. Since QStack can be inlined, this shouldn't severely affect performance... Reviewed-by: Marius Storm-Olsen
-rw-r--r--src/corelib/io/qdiriterator.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index ae5318f..8c7645e 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -183,29 +183,25 @@ void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo)
void QDirIteratorPrivate::advance()
{
while (!fileEngineIterators.isEmpty()) {
- QAbstractFileEngineIterator *it = fileEngineIterators.top();
// Find the next valid iterator that matches the filters.
- bool foundDirectory = false;
- while (it->hasNext()) {
+ while (fileEngineIterators.top()->hasNext()) {
+ QAbstractFileEngineIterator *it = fileEngineIterators.top();
it->next();
+
const QFileInfo info = it->currentFileInfo();
+ checkAndPushDirectory(it->currentFileInfo());
+
if (matchesFilters(it->currentFileName(), info)) {
currentFileInfo = nextFileInfo;
nextFileInfo = info;
- checkAndPushDirectory(nextFileInfo);
-
//We found a matching entry.
return;
-
- } else if (checkAndPushDirectory(info)) {
- foundDirectory = true;
- break;
}
}
- if (!foundDirectory)
- delete fileEngineIterators.pop();
+
+ delete fileEngineIterators.pop();
}
currentFileInfo = nextFileInfo;