diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-14 14:14:43 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-16 09:08:22 +0000 |
commit | 7dcada48d2435e8ceb0cc8a6771f79b76979e11f (patch) | |
tree | 30641af3adebeb94aa7e24339c577438ad82a724 /src/qml/compiler/qv4compiler.cpp | |
parent | f61a49efa2172dda996f33a7420b81fe33ad1692 (diff) |
Speed up string handling from QML cache files
Currently when extracting a string from a compilation unit, we copy the
data. This happens for example when instantiating objects and setting
string properties and it also happens when creating the JS runtime
strings from the compilation unit.
Since QML cache files that are mapped into memory from disk, we can
avoid the copy by keeping the files mapped and making sure that the
in-memory representation is compatible with QStringData.
This optimization is limited to little-endian architectures.
Task-number: QTBUG-63068
Change-Id: I2450aacd3bf1eda3e5be4264149b23f0281d8b4e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compiler.cpp')
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index bd9dd96d93..9b60ad14e6 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -90,7 +90,11 @@ void QV4::Compiler::StringTableGenerator::serialize(CompiledData::Unit *unit) const QString &qstr = strings.at(i); QV4::CompiledData::String *s = reinterpret_cast<QV4::CompiledData::String *>(stringData); + s->refcount = -1; s->size = qstr.length(); + s->allocAndCapacityReservedFlag = 0; + s->offsetOn32Bit = sizeof(QV4::CompiledData::String); + s->offsetOn64Bit = sizeof(QV4::CompiledData::String); #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN memcpy(s + 1, qstr.constData(), qstr.length()*sizeof(ushort)); #else @@ -98,6 +102,7 @@ void QV4::Compiler::StringTableGenerator::serialize(CompiledData::Unit *unit) for (int i = 0; i < qstr.length(); ++i) uc[i] = qToLittleEndian<ushort>(qstr.at(i).unicode()); #endif + reinterpret_cast<ushort *>(s + 1)[s->size] = 0; stringData += QV4::CompiledData::String::calculateSize(qstr); } |