diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-01-11 17:46:00 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-01-12 11:18:51 +0100 |
commit | 7660c30e08975011c7bd47bcb1796139b9d77196 (patch) | |
tree | 26e86cbc35560ac5bdf3327ea29f146cc1821787 /src/qml/jsruntime/qv4compilationunitmapper_p.h | |
parent | ccc4b52e95ac90c14c59001f675409c1a13c183b (diff) |
Cache static compilation units
If we load the same file multiple times, we can re-use the old mapping.
In fact we may leak memory if we don't. The fact that we have to use a
mutex here is somewhat regrettable, but I haven't found a better way
of serializing access.
Task-number: QTBUG-89659
Pick-to: 5.15
Change-Id: Iaa44ac80faa5e95f30c05e950ab35083a8b0416b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4compilationunitmapper_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4compilationunitmapper_p.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4compilationunitmapper_p.h b/src/qml/jsruntime/qv4compilationunitmapper_p.h index 80f914c141..10ad0a6ede 100644 --- a/src/qml/jsruntime/qv4compilationunitmapper_p.h +++ b/src/qml/jsruntime/qv4compilationunitmapper_p.h @@ -65,17 +65,20 @@ struct Unit; class CompilationUnitMapper { public: - CompilationUnitMapper(); ~CompilationUnitMapper(); - CompiledData::Unit *open(const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString); - void close(); + CompiledData::Unit *get( + const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString); private: + CompiledData::Unit *open( + const QString &cacheFilePath, const QDateTime &sourceTimeStamp, QString *errorString); + void close(); + #if defined(Q_OS_UNIX) - size_t length; + size_t length = 0; #endif - void *dataPtr; + void *dataPtr = nullptr; }; } |