diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-05-14 17:34:01 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-05-26 13:15:10 +0200 |
commit | 26290c8bca75c174cc1e6b24073ae480f8da3c66 (patch) | |
tree | 0d6561bddd82e0017d7def7eb661af73bfd99fab /tools | |
parent | 5ca899164156ee49770ef3749e6d4b1567c00362 (diff) |
qmllint: Introduce import caching
Previously we only cached processed qmldirs, now we cache full modules and dependencies.
This leads to manyfold speed increase (10 times in my tests) when lots of files are linted in one invocation of qmllint and those files have a lot of imports with shared dependencies.
Change-Id: Ifcd1eb9d620ca7a18c0a3d6395fbb6d003472dab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/main.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp index 424fabb84e..05bcc0fa13 100644 --- a/tools/qmllint/main.cpp +++ b/tools/qmllint/main.cpp @@ -50,9 +50,9 @@ #include <QtCore/qlibraryinfo.h> #endif -static bool lint_file(const QString &filename, const bool silent, - const QStringList &qmlImportPaths, const QStringList &qmltypesFiles, - const QString &resourceFile, const QMap<QString, QQmlJSLogger::Option> &options) +static bool lint_file(const QString &filename, const bool silent, const QStringList &qmlImportPaths, + const QStringList &qmltypesFiles, const QString &resourceFile, + const QMap<QString, QQmlJSLogger::Option> &options, QQmlJSImporter &importer) { QFile file(filename); if (!file.open(QFile::ReadOnly)) { @@ -88,7 +88,11 @@ static bool lint_file(const QString &filename, const bool silent, if (success && !isJavaScript) { const auto check = [&](QQmlJSResourceFileMapper *mapper) { - QQmlJSImporter importer(qmlImportPaths, mapper); + if (importer.importPaths() != qmlImportPaths) + importer.setImportPaths(qmlImportPaths); + + importer.setResourceFileMapper(mapper); + FindWarningVisitor v { &importer, qmltypesFiles, code, filename, silent }; for (auto it = options.cbegin(); it != options.cend(); ++it) { @@ -113,6 +117,7 @@ static bool lint_file(const QString &filename, const bool silent, int main(int argv, char *argc[]) { + qSetGlobalQHashSeed(0); QMap<QString, QQmlJSLogger::Option> options = QQmlJSLogger::options(); QCoreApplication app(argv, argc); @@ -260,13 +265,16 @@ All warnings can be set to three levels: QStringList qmltypesFiles {}; #endif bool success = true; + QQmlJSImporter importer(qmlImportPaths, nullptr); + #if QT_CONFIG(commandlineparser) for (const QString &filename : positionalArguments) #else const auto arguments = app.arguments(); for (const QString &filename : arguments) #endif - success &= lint_file(filename, silent, qmlImportPaths, qmltypesFiles, resourceFile, options); + success &= lint_file(filename, silent, qmlImportPaths, qmltypesFiles, resourceFile, options, + importer); return success ? 0 : -1; } |