From b9fd3e2836553dbe9c48c5d8784155b02a5699a2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 23 Sep 2009 15:17:32 +0200 Subject: detect and eliminate forwarding headers this will save quite some hash lookups (even if in empty hashes) and make the VisitRecorder bitmap smaller. --- tools/linguist/lupdate/cpp.cpp | 27 ++++++++++++++++++++------- 1 file 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 &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; -- cgit v0.12