aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8/qv8engine.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-01-14 16:22:33 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2015-01-21 18:22:52 +0100
commit8209f35b7961b7ea6867d7ebfb5288dcf40ecd71 (patch)
treef9e8b5083788574b75d7dba7f4ca1c60eded86fe /src/qml/qml/v8/qv8engine.cpp
parentd8131513b07d3f0a6d749c9961b294fc955fed6d (diff)
Rework QJSValue internals
Use a flagged pointer to either store a pointer to a QV4::Value (from the persistent storage) or a pointer to a QVariant in QJSValue::d. Like this we don't need to malloc to create a QJSValue for most use cases. Significantly reduces the memory consumption of QJSValue and speeds it up a lot. Change-Id: I10902cc4b6cc3f43d3f816875dc6c4bbb6b4490f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/v8/qv8engine.cpp')
-rw-r--r--src/qml/qml/v8/qv8engine.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp
index ce5d3c8370..73113be9ba 100644
--- a/src/qml/qml/v8/qv8engine.cpp
+++ b/src/qml/qml/v8/qv8engine.cpp
@@ -102,20 +102,18 @@ static void saveJSValue(QDataStream &stream, const void *data)
static void restoreJSValue(QDataStream &stream, void *data)
{
QJSValue *jsv = reinterpret_cast<QJSValue*>(data);
- QJSValuePrivate *d = QJSValuePrivate::get(*jsv);
quint32 isNullOrUndefined;
stream >> isNullOrUndefined;
- // ### Optimize for the common case where we have an valid persistent
- d->persistent.clear();
-
if (isNullOrUndefined & 0x1) {
- d->unboundData = QVariant(QMetaType::VoidStar, (void *)0);
+ *jsv = QJSValue(QJSValue::NullValue);
} else if (isNullOrUndefined & 0x2) {
- d->unboundData = QVariant();
+ *jsv = QJSValue();
} else {
- d->unboundData.load(stream);
+ QVariant v;
+ v.load(stream);
+ QJSValuePrivate::setVariant(jsv, v);
}
}