diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2011-10-10 11:56:43 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-19 10:25:28 +0200 |
commit | 9e92ecde74d33eddd39de88472964fb20feaaebf (patch) | |
tree | c127c382451255cf64d6259c33dc34c754e965b8 /dist/changes-3.1.0 | |
parent | ae30d71413595b3cb0550e047132ea07510d35a3 (diff) |
Provide API for "placement new" construction of meta-types
By making it possible to specify the place in memory where a
type should be constructed, any meta-type can be allocated on
the stack, for example. In the QML/JS QObject binding, this
makes it possible to call slots and access properties from
JavaScript without having to perform any mallocs (e.g. due to
QVariant creation) in the C++ <--> JS value conversion, in
the best case.
In addition to QMetaType::construct() and QMetaType::destruct(),
this change introduces QMetaType::typeSize(), which returns the
size of a type in bytes. This can be used to prepare a suitable
buffer for constructing a type using construct().
Benchmarks indicate that in-place construction is 2-5x faster
than normal construction for core and GUI types on linux-g++.
Note that there is already a QMetaType::construct() function
in Qt 4, which has been renamed to QMetaType::create() in Qt 5.
In order to avoid existing usages of construct() in user code
to call the Qt 5 construct() (when they really meant to call
create()), the third argument ("copy") of construct() is made
mandatory. Hence, calls to QMetaType::construct() written for
Qt 4 will cause a compile error when compiled with Qt 5, and
the user must adapt his code.
Task-number: QTBUG-12574
Change-Id: I836f06f6ee1c1c3edbd199a03424c78c942bdd3e
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'dist/changes-3.1.0')
0 files changed, 0 insertions, 0 deletions