From b220a20552838fbafbbf126b9e50d148ae76518d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 10 Apr 2015 12:34:46 +0200 Subject: Speed up value type binding creation * Avoid calling QMetaType::construct/destruct(typeId, ...) as that requires repeated lookups in the type registry. Instead cache the constructor/destructor/etc. function addresses in the QQmlValueType singletons as QMetaType * Allocate memory for the gadget pointer lazily, to accommodate the common case of a value type binding by property reference. Change-Id: I98a3ac73453b8f80027c06401b4f29a9707949d2 Reviewed-by: Lars Knoll --- src/qml/qml/qqmlvaluetypewrapper_p.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/qml/qml/qqmlvaluetypewrapper_p.h') diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index 0b8c30d0d5..6118511852 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE class QV8Engine; +class QQmlValueType; namespace QV4 { @@ -62,13 +63,12 @@ namespace Heap { struct QQmlValueTypeWrapper : Object { QQmlValueTypeWrapper(ExecutionEngine *engine); ~QQmlValueTypeWrapper(); - mutable QQmlRefPointer propertyCache; + QQmlRefPointer propertyCache; mutable void *gadgetPtr; - mutable int metaType; + QQmlValueType *valueType; void setValue(const QVariant &value) const; QVariant toVariant() const; - void *gadget() const { return gadgetPtr; } }; } @@ -84,8 +84,9 @@ public: static ReturnedValue create(ExecutionEngine *engine, const QVariant &, const QMetaObject *metaObject, int typeId); QVariant toVariant() const; - void toGadget(void *data) const; + bool toGadget(void *data) const; bool isEqual(const QVariant& value); + int typeId() const; static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static void put(Managed *m, String *name, const Value &value); -- cgit v1.2.3