From 6d4003b0fd742ee2be2e536091d5b65d72d01ce0 Mon Sep 17 00:00:00 2001 From: aavit Date: Wed, 8 Sep 2010 13:29:43 +0200 Subject: Shave 25% off test time by smarter qps script parsing --- tests/arthur/common/paintcommands.cpp | 27 ++++++++++++++++++++++++--- tests/arthur/common/paintcommands.h | 2 ++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index 70d419e..1d7b810 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -185,6 +185,7 @@ int PaintCommands::translateEnum(const char *table[], const QString &pattern, in QList PaintCommands::s_commandInfoTable = QList(); QList > PaintCommands::s_enumsTable = QList >(); +QMultiHash PaintCommands::s_commandHash; #define DECL_PAINTCOMMAND(identifier, method, regexp, syntax, sample) \ s_commandInfoTable << PaintCommandInfos(QLatin1String(identifier), &PaintCommands::method, QRegExp(regexp), \ @@ -627,6 +628,15 @@ void PaintCommands::staticInit() "\n - where vertices 1 to 4 defines the source quad and 5 to 8 the destination quad", "mapQuadToQuad 0.0 0.0 1.0 1.0 0.0 0.0 -1.0 -1.0"); + // populate the command lookup hash + for (int i=0; i= 0) { + if (scriptLine.isEmpty()) { + command_noop(QRegExp()); + return; + } + if (scriptLine.startsWith('#')) { + command_comment(QRegExp()); + return; + } + QString firstWord = scriptLine.section(QRegExp("\\s"), 0, 0); + QList indices = s_commandHash.values(firstWord); + foreach(int idx, indices) { + const PaintCommandInfos &command = s_commandInfoTable.at(idx); + if (command.regExp.indexIn(scriptLine) >= 0) { (this->*(command.paintMethod))(command.regExp); return; } + } qWarning("ERROR: unknown command or argument syntax error in \"%s\"", qPrintable(scriptLine)); } diff --git a/tests/arthur/common/paintcommands.h b/tests/arthur/common/paintcommands.h index aed4840..4d966b8 100644 --- a/tests/arthur/common/paintcommands.h +++ b/tests/arthur/common/paintcommands.h @@ -48,6 +48,7 @@ #include #include #include +#include QT_FORWARD_DECLARE_CLASS(QPainter) QT_FORWARD_DECLARE_CLASS(QRegExp) @@ -329,6 +330,7 @@ public: static QList s_commandInfoTable; static QList > s_enumsTable; + static QMultiHash s_commandHash; }; #endif // PAINTCOMMANDS_H -- cgit v0.12