aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsscope_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-12-09 20:11:46 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-13 16:31:44 +0000
commite8cd80e2a3603c40f0e477d9ba3717cfca43ce97 (patch)
tree35cba6a0e576115c69ffad926cd95b3f6efe1a9d /src/qmlcompiler/qqmljsscope_p.h
parent16b5983c64e2ada7441e92ac23a141671378edd9 (diff)
QQmlJSScope: Avoid unnecessary lazy loading
We can amend the factory to store additional information about the type. In particular we need its singleton status because that can be set from the qmldir, and we need the import that was used to load it for type resolution. Change-Id: Ia58a393fdb72711b4b9f99a11bc594920abcad07 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit d6c7617748e8fcb472333985f75e137a0b965e04) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qmlcompiler/qqmljsscope_p.h')
-rw-r--r--src/qmlcompiler/qqmljsscope_p.h67
1 files changed, 39 insertions, 28 deletions
diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h
index be34033b6d..a8b9d7a924 100644
--- a/src/qmlcompiler/qqmljsscope_p.h
+++ b/src/qmlcompiler/qqmljsscope_p.h
@@ -56,34 +56,6 @@
QT_BEGIN_NAMESPACE
class QQmlJSImporter;
-class QQmlJSScope;
-
-template<>
-class QDeferredFactory<QQmlJSScope>
-{
-public:
- QDeferredFactory() = default;
-
- QDeferredFactory(QQmlJSImporter *importer, const QString &filePath) :
- m_filePath(filePath), m_importer(importer)
- {}
-
- QQmlJSScope create() const;
-
- bool isValid() const
- {
- return !m_filePath.isEmpty() && m_importer != nullptr;
- }
-
- QString internalName() const
- {
- return QFileInfo(m_filePath).baseName();
- }
-
-private:
- QString m_filePath;
- QQmlJSImporter *m_importer = nullptr;
-};
class QQmlJSScope
{
@@ -505,6 +477,45 @@ private:
int m_runtimeId = -1; // an index counterpart of "foobar" in `id: foobar`
};
+template<>
+class QDeferredFactory<QQmlJSScope>
+{
+public:
+ QDeferredFactory() = default;
+
+ QDeferredFactory(QQmlJSImporter *importer, const QString &filePath) :
+ m_filePath(filePath), m_importer(importer)
+ {}
+
+ QQmlJSScope create() const;
+
+ bool isValid() const
+ {
+ return !m_filePath.isEmpty() && m_importer != nullptr;
+ }
+
+ QString internalName() const
+ {
+ return QFileInfo(m_filePath).baseName();
+ }
+
+ void setIsSingleton(bool isSingleton)
+ {
+ m_isSingleton = isSingleton;
+ }
+
+ void setImport(const QQmlJSScope::Import &import)
+ {
+ m_import = import;
+ }
+
+private:
+ QQmlJSScope::Import m_import;
+ QString m_filePath;
+ QQmlJSImporter *m_importer = nullptr;
+ bool m_isSingleton = false;
+};
+
struct QQmlJSExportedScope {
QQmlJSScope::Ptr scope;
QList<QQmlJSScope::Export> exports;