diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2021-10-11 14:57:50 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2021-10-20 10:27:40 +0200 |
commit | 7eefe948f9937a44cd6f1f2c06ea06a4ad21c70a (patch) | |
tree | e7fe2bd7047265853b726132b14b9a17aa8aa702 /src/corelib/mimetypes/qmimeprovider.cpp | |
parent | d23d2816fb963c22c330d60bcd0b212b08cc925b (diff) |
Optimize mime type matching
Don't count "*", don't search for "[" and for "?"
inside m_pattern on every call to matchFileName().
Do it once, when constructing the MimeGlobPattern.
Fix matching the pattern for names without any
wildcard: index of question mark should be -1, not
just different from 0.
This shortens loading a Qt6 project in Creator
by about 500 ms.
Change-Id: Ifa40c2cec4aba07a0312ef36877e571a8c8fb151
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 3c747aafa44ac2d0b314a002d2672227bf6513e5)
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/corelib/mimetypes/qmimeprovider.cpp')
-rw-r--r-- | src/corelib/mimetypes/qmimeprovider.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index 2a21c6e422..1c4ee1ce91 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -272,7 +272,6 @@ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile //qDebug() << pattern << mimeType << weight << caseSensitive; QMimeGlobPattern glob(pattern, QString() /*unused*/, weight, qtCaseSensitive); - // TODO: this could be done faster for literals where a simple == would do. if (glob.matchFileName(fileName)) result.addMatch(QLatin1String(mimeType), weight, pattern); } |