summaryrefslogtreecommitdiffstats
path: root/tools/linguist/lupdate
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-08-18 15:31:05 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-09-23 13:44:26 (GMT)
commit5fc344431354c00340d9727f64dbb3c29972f93d (patch)
tree9d9e5163e2cc6fee1ef26dafb14415b908757117 /tools/linguist/lupdate
parentf64753362edf6c22879b1f39e83de1f69b8dda77 (diff)
downloadQt-5fc344431354c00340d9727f64dbb3c29972f93d.zip
Qt-5fc344431354c00340d9727f64dbb3c29972f93d.tar.gz
Qt-5fc344431354c00340d9727f64dbb3c29972f93d.tar.bz2
optimize directory scanning
qdiroperator uses qregexp for filtering, which is sloooow. so use a hash lookup on extensions instead.
Diffstat (limited to 'tools/linguist/lupdate')
-rw-r--r--tools/linguist/lupdate/main.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index 3cba90d..e8cf121 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -62,23 +62,14 @@ static void printOut(const QString & out)
}
static void recursiveFileInfoList(const QDir &dir,
- const QStringList &nameFilters, QDir::Filters filter, bool recursive,
+ const QSet<QString> &nameFilters, QDir::Filters filter,
QFileInfoList *fileinfolist)
{
- if (recursive)
- filter |= QDir::AllDirs;
- QFileInfoList entries = dir.entryInfoList(nameFilters, filter);
-
- QFileInfoList::iterator it;
- for (it = entries.begin(); it != entries.end(); ++it) {
- QString fname = it->fileName();
- if (fname != QLatin1String(".") && fname != QLatin1String("..")) {
- if (it->isDir())
- recursiveFileInfoList(QDir(it->absoluteFilePath()), nameFilters, filter, recursive, fileinfolist);
- else
- fileinfolist->append(*it);
- }
- }
+ foreach (const QFileInfo &fi, dir.entryInfoList(filter))
+ if (fi.isDir())
+ recursiveFileInfoList(QDir(fi.absoluteFilePath()), nameFilters, filter, fileinfolist);
+ else if (nameFilters.contains(fi.suffix()))
+ fileinfolist->append(fi);
}
static void printUsage()
@@ -243,7 +234,7 @@ int main(int argc, char **argv)
bool recursiveScan = true;
QString extensions = m_defaultExtensions;
- QStringList extensionsNameFilters;
+ QSet<QString> extensionsNameFilters;
for (int i = 1; i < argc; ++i) {
if (args.at(i) == QLatin1String("-ts"))
@@ -418,15 +409,15 @@ int main(int argc, char **argv)
foreach (QString ext, extensions.split(QLatin1Char(','))) {
ext = ext.trimmed();
if (ext.startsWith(QLatin1Char('.')))
- ext.remove(0,1);
- ext.insert(0, QLatin1String("*."));
- extensionsNameFilters << ext;
+ ext.remove(0, 1);
+ extensionsNameFilters.insert(ext);
}
}
QDir::Filters filters = QDir::Files | QDir::NoSymLinks;
+ if (recursiveScan)
+ filters |= QDir::AllDirs | QDir::NoDotAndDotDot;
QFileInfoList fileinfolist;
- recursiveFileInfoList(dir, extensionsNameFilters, filters,
- recursiveScan, &fileinfolist);
+ recursiveFileInfoList(dir, extensionsNameFilters, filters, &fileinfolist);
int scanRootLen = dir.absolutePath().length();
foreach (const QFileInfo &fi, fileinfolist) {
QString fn = QDir::cleanPath(fi.absoluteFilePath());