summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/moc.cpp2
-rw-r--r--src/tools/moc/parser.h5
-rw-r--r--src/tools/moc/preprocessor.cpp9
-rw-r--r--src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp2
-rw-r--r--src/tools/rcc/main.cpp2
5 files changed, 15 insertions, 5 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 726d1972f1..0cdf9918ab 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1444,7 +1444,7 @@ bool Moc::until(Token target) {
case LPAREN: ++parenCount; break;
case RPAREN: --parenCount; break;
case LANGLE:
- if (parenCount == 0 && braceCount == 0 && parenCount == 0)
+ if (parenCount == 0 && braceCount == 0)
++angleCount;
break;
case RANGLE:
diff --git a/src/tools/moc/parser.h b/src/tools/moc/parser.h
index 947e472dae..6b281eb339 100644
--- a/src/tools/moc/parser.h
+++ b/src/tools/moc/parser.h
@@ -34,9 +34,10 @@
#ifndef PARSER_H
#define PARSER_H
-#include <qstack.h>
#include "symbols.h"
+#include <stack>
+
QT_BEGIN_NAMESPACE
class Parser
@@ -57,7 +58,7 @@ public:
};
QList<IncludePath> includes;
- QStack<QByteArray> currentFilenames;
+ std::stack<QByteArray, QByteArrayList> currentFilenames;
inline bool hasNext() const { return (index < symbols.size()); }
inline Token next() { if (index >= symbols.size()) return NOTOKEN; return symbols.at(index++).token; }
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index a2a1a958cf..a47896d722 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -154,6 +154,11 @@ bool Preprocessor::skipBranch()
Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocessor::TokenizeMode mode)
{
Symbols symbols;
+ // Preallocate some space to speed up the code below.
+ // The magic divisor value was found by calculating the average ratio between
+ // input size and the final size of symbols.
+ // This yielded a value of 16.x when compiling Qt Base.
+ symbols.reserve(input.size() / 16);
const char *begin = input.constData();
const char *data = begin;
while (*data) {
@@ -1217,6 +1222,10 @@ Symbols Preprocessor::preprocessed(const QByteArray &filename, QFile *file)
// phase 3: preprocess conditions and substitute macros
Symbols result;
+ // Preallocate some space to speed up the code below.
+ // The magic value was found by logging the final size
+ // and calculating an average when running moc over FOSS projects.
+ result.reserve(file->size() / 300000);
preprocess(filename, result);
mergeStringLiterals(&result);
diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
index 2825e0b7a3..59791d1524 100644
--- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
+++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp
@@ -420,7 +420,7 @@ int main(int argc, char **argv)
pp.macros["Q_MOC_RUN"];
pp.macros["__cplusplus"];
- const QByteArray filename = QFile::decodeName(argv[i]).toLatin1();
+ const QByteArray filename = arg.toLocal8Bit();
moc.filename = filename;
moc.currentFilenames.push(filename);
diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp
index d8d5728414..1405f19a3a 100644
--- a/src/tools/rcc/main.cpp
+++ b/src/tools/rcc/main.cpp
@@ -304,7 +304,7 @@ int main(int argc, char *argv[])
{
// rcc uses a QHash to store files in the resource system.
// we must force a certain hash order when testing or tst_rcc will fail, see QTBUG-25078
- if (!qEnvironmentVariableIsEmpty("QT_RCC_TEST") && !qt_qhash_seed.testAndSetRelaxed(-1, 0))
+ if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_RCC_TEST") && !qt_qhash_seed.testAndSetRelaxed(-1, 0)))
qFatal("Cannot force QHash seed for testing as requested");
return QT_PREPEND_NAMESPACE(runRcc)(argc, argv);