Details
-
Task
-
Resolution: Done
-
P2: Important
-
None
-
None
-
9e92ecde74d33eddd39de88472964fb20feaaebf
Description
Currently, the two ways of constructing a meta-type instance are
1) QVariant(int type, void *copy = 0). This will use QVariant::Private::Data to store the data if the type fits, and will heap-allocate otherwise; or
2) void *QMetaType::construct(int type, void *copy = 0). This will always heap-allocate.
It should be possible to construct a meta-type by passing a type id and the address of where to construct the new instance. This would make it possible to construct any meta-type on the stack, or to allocate the type using a custom memory pool. For 1) it also avoids the overhead of invoking the QVariant constructor and destructor. This is important in order to make QtScript's QObject bindings perform better (currently every slot call or property access from QtScript creates one or more variants to hold the converted JS arguments & return value).