Make QDateTime::Data::CanBeSmall a static constexpr bool
Using enum for named constants is old-fashioned. Also test it using if constexpr, since we can. Change-Id: I1fc4ed975e12403bc724b39f9335f3797acfafb8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
80686be086
commit
9031574440
@ -2782,7 +2782,7 @@ static inline bool specCanBeSmall(Qt::TimeSpec spec)
|
|||||||
|
|
||||||
static inline bool msecsCanBeSmall(qint64 msecs)
|
static inline bool msecsCanBeSmall(qint64 msecs)
|
||||||
{
|
{
|
||||||
if (!QDateTimeData::CanBeSmall)
|
if constexpr (!QDateTimeData::CanBeSmall)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ShortData sd;
|
ShortData sd;
|
||||||
@ -3161,7 +3161,7 @@ inline bool QDateTime::Data::isShort() const
|
|||||||
|
|
||||||
// even if CanBeSmall = false, we have short data for a default-constructed
|
// even if CanBeSmall = false, we have short data for a default-constructed
|
||||||
// QDateTime object. But it's unlikely.
|
// QDateTime object. But it's unlikely.
|
||||||
if (CanBeSmall)
|
if constexpr (CanBeSmall)
|
||||||
return Q_LIKELY(b);
|
return Q_LIKELY(b);
|
||||||
return Q_UNLIKELY(b);
|
return Q_UNLIKELY(b);
|
||||||
}
|
}
|
||||||
|
@ -281,12 +281,10 @@ class Q_CORE_EXPORT QDateTime
|
|||||||
};
|
};
|
||||||
|
|
||||||
union Data {
|
union Data {
|
||||||
enum {
|
// To be of any use, we need at least 60 years around 1970, which
|
||||||
// To be of any use, we need at least 60 years around 1970, which
|
// is 1,893,456,000,000 ms. That requires 41 bits to store, plus
|
||||||
// is 1,893,456,000,000 ms. That requires 41 bits to store, plus
|
// the sign bit. With the status byte, the minimum size is 50 bits.
|
||||||
// the sign bit. With the status byte, the minimum size is 50 bits.
|
static constexpr bool CanBeSmall = sizeof(ShortData) * 8 > 50;
|
||||||
CanBeSmall = sizeof(ShortData) * 8 > 50
|
|
||||||
};
|
|
||||||
|
|
||||||
Data() noexcept;
|
Data() noexcept;
|
||||||
Data(const QTimeZone &);
|
Data(const QTimeZone &);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user