diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2017-03-27 14:57:24 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2017-03-27 15:18:15 +0000 |
commit | 437af83c9ad8ae31e8f72b49765ebfc560dcfc7b (patch) | |
tree | 53bb8a69209e91b790e042829a9e501a34bce272 /src/plugins/qmljstools/qmljsmodelmanager.cpp | |
parent | 767d988891ea7ea376e1e807fe921c9001b4abdf (diff) |
QmlJSModelManager: Avoid needless Mime database lookups
This speeds up processing of a cmake project without any QML files by a
factor of 16 on my machine.
Task-number: QTCREATORBUG-17884
Change-Id: I823d4a051451adbca10a8b73c17d288e03387378
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/qmljstools/qmljsmodelmanager.cpp')
-rw-r--r-- | src/plugins/qmljstools/qmljsmodelmanager.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index cfbde13308..e13bbb3e29 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -38,6 +38,7 @@ #include <projectexplorer/buildconfiguration.h> #include <projectexplorer/project.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/projectnodes.h> #include <projectexplorer/projecttree.h> #include <projectexplorer/session.h> #include <projectexplorer/target.h> @@ -59,6 +60,8 @@ #include <QTextStream> #include <QTimer> #include <QRegExp> +#include <QSet> +#include <QString> #include <QLibraryInfo> #include <qglobal.h> @@ -74,20 +77,18 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( Project *project) const { ModelManagerInterface::ProjectInfo projectInfo(project); - Target *activeTarget = 0; + Target *activeTarget = nullptr; if (project) { - QSet<QString> qmlTypeNames; - qmlTypeNames << QLatin1String(Constants::QML_MIMETYPE) - << QLatin1String(Constants::QBS_MIMETYPE) - << QLatin1String(Constants::QMLPROJECT_MIMETYPE) - << QLatin1String(Constants::QMLTYPES_MIMETYPE) - << QLatin1String(Constants::QMLUI_MIMETYPE); - foreach (const QString &filePath, project->files(Project::SourceFiles)) { - if (qmlTypeNames.contains(Utils::mimeTypeForFile( - filePath, MimeMatchMode::MatchExtension).name())) { - projectInfo.sourceFiles << filePath; - } - } + const QSet<QString> qmlTypeNames = { Constants::QML_MIMETYPE ,Constants::QBS_MIMETYPE, + Constants::QMLPROJECT_MIMETYPE, + Constants::QMLTYPES_MIMETYPE, + Constants::QMLUI_MIMETYPE }; + projectInfo.sourceFiles = project->files(Project::SourceFiles, + [&qmlTypeNames](const FileNode *fn) { + return fn->fileType() == FileType::QML + && qmlTypeNames.contains(Utils::mimeTypeForFile(fn->filePath().toString(), + MimeMatchMode::MatchExtension).name()); + }); activeTarget = project->activeTarget(); } Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit(); |