From 7dcada48d2435e8ceb0cc8a6771f79b76979e11f Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 14 May 2018 14:14:43 +0200 Subject: 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 Reviewed-by: Lars Knoll Reviewed-by: Erik Verbruggen --- src/qml/compiler/qv4compiler.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/qml/compiler/qv4compiler.cpp') 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(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(qstr.at(i).unicode()); #endif + reinterpret_cast(s + 1)[s->size] = 0; stringData += QV4::CompiledData::String::calculateSize(qstr); } -- cgit v1.2.3