Make use of the internal space for enum in QVariant
Enums are movable even if they have not been tagged as such, and therefore can safely make use of the internal storage. Change-Id: I3bec8556bfeb4a07cb30d918f8d1dd2565d6d94a Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>bb10
parent
4fb04b0bd7
commit
9fda89f97d
|
|
@ -841,7 +841,7 @@ static void customConstruct(QVariant::Private *d, const void *copy)
|
|||
|
||||
// this logic should match with QVariantIntegrator::CanUseInternalSpace
|
||||
if (size <= sizeof(QVariant::Private::Data)
|
||||
&& (type.flags() & QMetaType::MovableType)) {
|
||||
&& (type.flags() & (QMetaType::MovableType | QMetaType::IsEnumeration))) {
|
||||
type.construct(&d->data.ptr, copy);
|
||||
d->is_shared = false;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ template<typename T>
|
|||
struct QVariantIntegrator
|
||||
{
|
||||
static const bool CanUseInternalSpace = sizeof(T) <= sizeof(QVariant::Private::Data)
|
||||
&& (!QTypeInfo<T>::isStatic);
|
||||
&& ((!QTypeInfo<T>::isStatic) || Q_IS_ENUM(T));
|
||||
};
|
||||
Q_STATIC_ASSERT(QVariantIntegrator<double>::CanUseInternalSpace);
|
||||
Q_STATIC_ASSERT(QVariantIntegrator<long int>::CanUseInternalSpace);
|
||||
|
|
|
|||
Loading…
Reference in New Issue