diff options
author | Ulf Hermann <[email protected]> | 2024-01-24 08:13:14 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2024-01-25 06:54:19 +0100 |
commit | 27a4b275e3623b27bc0c9b17c3b144a74f713bb5 (patch) | |
tree | 0112dfc2109fb496654ba6806ac6faa454c252d4 /src/qml/jsruntime/qv4engine_p.h | |
parent | f1f81bad2bbef80078735adcb92278953d57ec31 (diff) |
QtQml: Use a multihash to store executable CUs
You can produce multiple CUs for the same URL with createQmlObject() and
friends. They need to be marked during garbage collection and therefore
the engine needs to keep track of them.
With the multihash there can be a lot of CUs of the same URL. Searching
through them can take a lot of time. However, there is no point in
searching for an existing executable CU if we've just freshly compiled
the base CU. So, in those cases, insert directly instead.
Fixes: QTBUG-121436
Change-Id: I804dbc74d2ade118f6680a7fbde3f234699ccbc3
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4engine_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 28242d35c8..1f4622d154 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -754,9 +754,18 @@ public: const QUrl &url, const QString &sourceCode, const QDateTime &sourceTimeStamp); QQmlRefPointer<ExecutableCompilationUnit> compilationUnitForUrl(const QUrl &url) const; + QQmlRefPointer<ExecutableCompilationUnit> executableCompilationUnit( QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit); - QHash<QUrl, QQmlRefPointer<ExecutableCompilationUnit>> compilationUnits() const + + QQmlRefPointer<ExecutableCompilationUnit> insertCompilationUnit( + QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit) { + QUrl url = unit->finalUrl(); + return *m_compilationUnits.insert( + std::move(url), ExecutableCompilationUnit::create(std::move(unit), this)); + } + + QMultiHash<QUrl, QQmlRefPointer<ExecutableCompilationUnit>> compilationUnits() const { return m_compilationUnits; } @@ -878,7 +887,7 @@ private: QVector<Deletable *> m_extensionData; - QHash<QUrl, QQmlRefPointer<ExecutableCompilationUnit>> m_compilationUnits; + QMultiHash<QUrl, QQmlRefPointer<ExecutableCompilationUnit>> m_compilationUnits; // QV4::PersistentValue would be preferred, but using QHash will create copies, // and QV4::PersistentValue doesn't like creating copies. |