QmlJS: Limit MIME type matching to extension

This improves performance of MIME type resolving on project loading.

When the MIME type cannot be resolved uniquely by extension to >50 weight,
the file preamble is read in order to match against magic values in the
MIME database.

In 3953e2b447862576902abef11ffb4efc56d7a625 the weight of the standard
file extensions was increased to 70, to at least avoid expensive matching
when the answer is obvious.

Qml types only have glob patterns anyway, so this shouldn't break
anything.

Change-Id: If3add50809a4361f877ea261fba6d6f333b2b740
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2016-02-28 14:59:26 +02:00
committed by Orgad Shaneh
parent ba517fcfab
commit e5459fb9dc

View File

@@ -84,8 +84,10 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject(
<< QLatin1String(Constants::QMLTYPES_MIMETYPE)
<< QLatin1String(Constants::QMLUI_MIMETYPE);
foreach (const QString &filePath, project->files(Project::SourceFiles)) {
if (qmlTypeNames.contains(mdb.mimeTypeForFile(filePath).name()))
if (qmlTypeNames.contains(mdb.mimeTypeForFile(
filePath, MimeDatabase::MatchExtension).name())) {
projectInfo.sourceFiles << filePath;
}
}
activeTarget = project->activeTarget();
}