summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.h
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>2014-10-31 16:07:39 +0100
committerJędrzej Nowacki <jedrzej.nowacki@digia.com>2014-11-17 10:18:43 +0100
commit3d575d4845926bd141ff0c14e57427bba79644d0 (patch)
tree7469e62bee4b113ba5bd6d69fed90493a44d4711 /src/corelib/kernel/qmetatype.h
parent78e0e72eb5ec2c5b107523b8af48fdedd599bba7 (diff)
Reduce code bloat, by cleaning up QMetaTypeFunctionHelper
Create and Delete wrappers are not necessary, because they can be easily simulated with Construct and Destruct. This change removes redundant function wrappers and a bit of over-optimized code. Gain is quite big: Before: text data bss dec hex filename 5366008 47460 14904 5428372 52d494 libQt5Core.so.5.5.0 505578 7060 2124 514762 7daca libQt5DBus.so.5.5.0 5591079 134656 6728 5732463 57786f libQt5Gui.so.5.5.0 1398785 31676 2576 1433037 15ddcd libQt5Network.so.5.5.0 6642431 220952 2536 6865919 68c3ff libQt5Widgets.so.5.5.0 After: text data bss dec hex filename 5342559 47460 14904 5404923 5278fb libQt5Core.so.5.5.0 496025 7068 2124 505217 7b581 libQt5DBus.so.5.5.0 5579291 134272 6728 5720291 5748e3 libQt5Gui.so.5.5.0 1389461 31676 2576 1423713 15b961 libQt5Network.so.5.5.0 6637139 220952 2536 6860627 68af53 libQt5Widgets.so.5.5.0 Cost of the change, is moved to CPU while calling QMetaType create() and destroy(), these two functions became a bit slower. The cost should not be visible, because they call operator new anyway. Change-Id: I34fd410343377d9c29925675d7da8172bfda9ce6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/corelib/kernel/qmetatype.h')
-rw-r--r--src/corelib/kernel/qmetatype.h25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index dc7e7e0395..e89b3affc6 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -471,6 +471,11 @@ public:
int size,
QMetaType::TypeFlags flags,
const QMetaObject *metaObject);
+ static int registerNormalizedType(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, Destructor destructor,
+ Constructor constructor,
+ int size,
+ QMetaType::TypeFlags flags,
+ const QMetaObject *metaObject);
static int registerTypedef(const char *typeName, int aliasId);
static int registerNormalizedTypedef(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, int aliasId);
static int type(const char *typeName);
@@ -668,8 +673,8 @@ public:
static void unregisterConverterFunction(int from, int to);
private:
- Creator m_creator;
- Deleter m_deleter;
+ Creator m_creator_unused;
+ Deleter m_deleter_unused;
SaveOperator m_saveOp;
LoadOperator m_loadOp;
Constructor m_constructor;
@@ -1618,8 +1623,6 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz
flags |= QMetaType::WasDeclaredAsMetaType;
const int id = QMetaType::registerNormalizedType(normalizedTypeName,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Delete,
- QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Create,
QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Destruct,
QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Construct,
int(sizeof(T)),
@@ -1988,8 +1991,8 @@ inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeI
uint theTypeFlags,
int typeId,
const QMetaObject *_metaObject)
- : m_creator(creator)
- , m_deleter(deleter)
+ : m_creator_unused(creator)
+ , m_deleter_unused(deleter)
, m_saveOp(saveOp)
, m_loadOp(loadOp)
, m_constructor(constructor)
@@ -2023,16 +2026,14 @@ inline bool QMetaType::isRegistered() const
inline void *QMetaType::create(const void *copy) const
{
- if (Q_UNLIKELY(isExtended(CreateEx)))
- return createExtended(copy);
- return m_creator(copy);
+ // ### TODO Qt6 remove the extension
+ return createExtended(copy);
}
inline void QMetaType::destroy(void *data) const
{
- if (Q_UNLIKELY(isExtended(DestroyEx)))
- return destroyExtended(data);
- m_deleter(data);
+ // ### TODO Qt6 remove the extension
+ destroyExtended(data);
}
inline void *QMetaType::construct(void *where, const void *copy) const