diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-07-12 16:44:03 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-07-16 18:33:44 +0200 |
commit | d2c6ac8d5eaa1d4b53b647f01c53d821bbba4665 (patch) | |
tree | 0b006fe452155eb3806995dc5094ffb36a242d80 /src/qml/qml/qqmltypeloader_p.h | |
parent | 53bb052704eed8672bbb37fcc6741d33c82177bd (diff) |
Clean up import resolution handling
Instead of storing raw pointers into the compiled data and creating
synthetic CompiledData::Import objects for implicit imports, this patch
introduces a dedicated PendingImport data structure that removes the
need of using raw pointers, reduces the amount of string index to string
resolution and incorporates the priority field thus eliminating the need
for a hash table.
Change-Id: Ia59aad17687bc0935aafd36236bda85d5f4f82a2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypeloader_p.h')
-rw-r--r-- | src/qml/qml/qqmltypeloader_p.h | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index 5710bdba56..f8cec700a5 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -61,6 +61,8 @@ #include <QtCore/qcache.h> #include <QtCore/qmutex.h> +#include <memory> + QT_BEGIN_NAMESPACE class QQmlScriptBlob; @@ -87,11 +89,31 @@ public: void setCachedUnitStatus(QQmlMetaType::CachedUnitLookupError status) { m_cachedUnitStatus = status; } + struct PendingImport + { + QV4::CompiledData::Import::ImportType type = QV4::CompiledData::Import::ImportType::ImportLibrary; + + QString uri; + QString qualifier; + + int majorVersion = -1; + int minorVersion = -1; + + QV4::CompiledData::Location location; + + int priority = 0; + + PendingImport() = default; + PendingImport(Blob *blob, const QV4::CompiledData::Import *import); + }; + using PendingImportPtr = std::shared_ptr<PendingImport>; + protected: bool addImport(const QV4::CompiledData::Import *import, QList<QQmlError> *errors); + bool addImport(PendingImportPtr import, QList<QQmlError> *errors); - bool fetchQmldir(const QUrl &url, const QV4::CompiledData::Import *import, int priority, QList<QQmlError> *errors); - bool updateQmldir(const QQmlRefPointer<QQmlQmldirData> &data, const QV4::CompiledData::Import *import, QList<QQmlError> *errors); + bool fetchQmldir(const QUrl &url, PendingImportPtr import, int priority, QList<QQmlError> *errors); + bool updateQmldir(const QQmlRefPointer<QQmlQmldirData> &data, PendingImportPtr import, QList<QQmlError> *errors); private: virtual bool qmldirDataAvailable(const QQmlRefPointer<QQmlQmldirData> &, QList<QQmlError> *); @@ -109,7 +131,7 @@ public: static bool diskCacheForced(); QQmlImports m_importCache; - QHash<const QV4::CompiledData::Import*, int> m_unresolvedImports; + QVector<PendingImportPtr> m_unresolvedImports; QVector<QQmlRefPointer<QQmlQmldirData>> m_qmldirs; QQmlMetaType::CachedUnitLookupError m_cachedUnitStatus = QQmlMetaType::CachedUnitLookupError::NoError; }; |