summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatteo Bertozzi <theo.bertozzi@gmail.com>2009-05-17 13:19:31 (GMT)
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-27 14:48:49 (GMT)
commit884eb97fe9eab4ee84dd8aafb026fd918906cf9a (patch)
tree3b22075dffbc5613d79cc38bac52269cc288c47a /util
parent37fc695ff9f82038b2db4e4de976f6f64daffa5f (diff)
downloadQt-884eb97fe9eab4ee84dd8aafb026fd918906cf9a.zip
Qt-884eb97fe9eab4ee84dd8aafb026fd918906cf9a.tar.gz
Qt-884eb97fe9eab4ee84dd8aafb026fd918906cf9a.tar.bz2
Speed up util/normalize dir iteration
Use QDirIterator to speed up iterating over directories in normalize util. Reviewed-by: Eskil
Diffstat (limited to 'util')
-rw-r--r--util/normalize/main.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/util/normalize/main.cpp b/util/normalize/main.cpp
index 905c1ec..b16335e 100644
--- a/util/normalize/main.cpp
+++ b/util/normalize/main.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
#include <qcoreapplication.h>
-#include <qdir.h>
+#include <qdiriterator.h>
#include <qfile.h>
#include <qmetaobject.h>
#include <qstring.h>
@@ -140,18 +140,14 @@ void check(const QString &fileName)
void traverse(const QString &path)
{
- QDir dir(path);
- dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoSymLinks);
-
- const QFileInfoList list = dir.entryInfoList();
- for (int i = 0; i < list.count(); ++i) {
- const QFileInfo fi = list.at(i);
- if (fi.fileName() == QLatin1String(".") || fi.fileName() == QLatin1String(".."))
- continue;
- if (fi.fileName().endsWith(".cpp"))
- check(path + fi.fileName());
- if (fi.isDir())
- traverse(path + fi.fileName() + "/"); // recurse
+ QDirIterator dirIterator(path, QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::NoSymLinks);
+
+ while (dirIterator.hasNext()) {
+ QString filePath = dirIterator.next();
+ if (filePath.endsWith(".cpp"))
+ check(filePath);
+ else if (QFileInfo(filePath).isDir())
+ traverse(filePath); // recurse
}
}