Micro-optimize QVariant enum to number conversions
Change-Id: I2296d9417e0d1ef08084fb259885ac2a3eff9fe8 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
c294067e4b
commit
cc1d9671b3
@ -220,8 +220,9 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
|
|||||||
return qlonglong(qMetaTypeUNumber(d));
|
return qlonglong(qMetaTypeUNumber(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QMetaType::typeFlags(d->type) & QMetaType::IsEnumeration) {
|
QMetaType typeInfo(d->type);
|
||||||
switch (QMetaType::sizeOf(d->type)) {
|
if (typeInfo.flags() & QMetaType::IsEnumeration) {
|
||||||
|
switch (typeInfo.sizeOf()) {
|
||||||
case 1:
|
case 1:
|
||||||
return d->is_shared ? *reinterpret_cast<signed char *>(d->data.shared->ptr) : d->data.sc;
|
return d->is_shared ? *reinterpret_cast<signed char *>(d->data.shared->ptr) : d->data.sc;
|
||||||
case 2:
|
case 2:
|
||||||
@ -268,8 +269,9 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
|
|||||||
return qMetaTypeUNumber(d);
|
return qMetaTypeUNumber(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QMetaType::typeFlags(d->type) & QMetaType::IsEnumeration) {
|
QMetaType typeInfo(d->type);
|
||||||
switch (QMetaType::sizeOf(d->type)) {
|
if (typeInfo.flags() & QMetaType::IsEnumeration) {
|
||||||
|
switch (typeInfo.sizeOf()) {
|
||||||
case 1:
|
case 1:
|
||||||
return d->is_shared ? *reinterpret_cast<uchar *>(d->data.shared->ptr) : d->data.uc;
|
return d->is_shared ? *reinterpret_cast<uchar *>(d->data.shared->ptr) : d->data.uc;
|
||||||
case 2:
|
case 2:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user