summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-09-23 13:17:32 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-09-23 13:45:06 (GMT)
commitb9fd3e2836553dbe9c48c5d8784155b02a5699a2 (patch)
treee9114781f427cd6e67fed59c8dc955e452147516 /tools
parent0040d5a582b7fb7e9719d7c04c8de272e2a1389d (diff)
downloadQt-b9fd3e2836553dbe9c48c5d8784155b02a5699a2.zip
Qt-b9fd3e2836553dbe9c48c5d8784155b02a5699a2.tar.gz
Qt-b9fd3e2836553dbe9c48c5d8784155b02a5699a2.tar.bz2
detect and eliminate forwarding headers
this will save quite some hash lookups (even if in empty hashes) and make the VisitRecorder bitmap smaller.
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/lupdate/cpp.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 0a710e2..ed41edb 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -175,7 +175,7 @@ class CppFiles {
public:
static const ParseResults *getResults(const QString &cleanFile);
- static void setResults(const QString &cleanFile, ParseResults *results);
+ static void setResults(const QString &cleanFile, const ParseResults *results);
static const Translator *getTranslator(const QString &cleanFile);
static void setTranslator(const QString &cleanFile, const Translator *results);
static bool isBlacklisted(const QString &cleanFile);
@@ -1188,9 +1188,8 @@ const ParseResults *CppFiles::getResults(const QString &cleanFile)
return parsedFiles().value(cleanFile);
}
-void CppFiles::setResults(const QString &cleanFile, ParseResults *results)
+void CppFiles::setResults(const QString &cleanFile, const ParseResults *results)
{
- results->fileId = nextFileId++;
parsedFiles().insert(cleanFile, results);
}
@@ -2055,14 +2054,28 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
const ParseResults *CppParser::recordResults(bool isHeader)
{
if (tor) {
- if (tor->messageCount())
+ if (tor->messageCount()) {
CppFiles::setTranslator(yyFileName, tor);
- else
+ } else {
delete tor;
+ tor = 0;
+ }
}
if (isHeader) {
- CppFiles::setResults(yyFileName, results);
- return results;
+ const ParseResults *pr;
+ if (!tor && results->includes.count() == 1
+ && results->rootNamespace.children.isEmpty()
+ && results->rootNamespace.aliases.isEmpty()
+ && results->rootNamespace.usings.isEmpty()) {
+ // This is a forwarding header. Slash it.
+ pr = *results->includes.begin();
+ delete results;
+ } else {
+ results->fileId = nextFileId++;
+ pr = results;
+ }
+ CppFiles::setResults(yyFileName, pr);
+ return pr;
} else {
delete results;
return 0;