Reduce QtCoreLib size by not repeating "UTC" string too often.
It is a minor reduction, in release build it is ~200 bytes Change-Id: I4f7972c95769f2e0ca1ddc935ff7a0a6b4379e2a Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
5026835690
commit
ce14208c38
@ -3194,7 +3194,7 @@ QTimeZone QDateTime::timeZone() const
|
||||
return d->m_timeZone;
|
||||
case Qt::UTC:
|
||||
if (!d->m_timeZone.isValid())
|
||||
d->m_timeZone = QTimeZone("UTC");
|
||||
d->m_timeZone = QTimeZone(QTimeZonePrivate::utcQByteArray());
|
||||
return d->m_timeZone;
|
||||
case Qt::TimeZone :
|
||||
return d->m_timeZone;
|
||||
@ -3254,9 +3254,9 @@ QString QDateTime::timeZoneAbbreviation() const
|
||||
{
|
||||
switch (d->m_spec) {
|
||||
case Qt::UTC:
|
||||
return QStringLiteral("UTC");
|
||||
return QTimeZonePrivate::utcQString();
|
||||
case Qt::OffsetFromUTC:
|
||||
return QLatin1String("UTC") + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
|
||||
return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
|
||||
case Qt::TimeZone:
|
||||
#ifndef QT_BOOTSTRAPPED
|
||||
return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch());
|
||||
|
@ -558,8 +558,8 @@ template<> QTimeZonePrivate *QSharedDataPointer<QTimeZonePrivate>::clone()
|
||||
// Create default UTC time zone
|
||||
QUtcTimeZonePrivate::QUtcTimeZonePrivate()
|
||||
{
|
||||
const QString name = QStringLiteral("UTC");
|
||||
init(QByteArrayLiteral("UTC"), 0, name, name, QLocale::AnyCountry, name);
|
||||
const QString name = utcQString();
|
||||
init(utcQByteArray(), 0, name, name, QLocale::AnyCountry, name);
|
||||
}
|
||||
|
||||
// Create a named UTC time zone
|
||||
@ -583,7 +583,7 @@ QUtcTimeZonePrivate::QUtcTimeZonePrivate(qint32 offsetSeconds)
|
||||
QString utcId;
|
||||
|
||||
if (offsetSeconds == 0)
|
||||
utcId = QStringLiteral("UTC");
|
||||
utcId = utcQString();
|
||||
else
|
||||
utcId = isoOffsetFormat(offsetSeconds);
|
||||
|
||||
@ -675,7 +675,7 @@ qint32 QUtcTimeZonePrivate::daylightTimeOffset(qint64 atMSecsSinceEpoch) const
|
||||
|
||||
QByteArray QUtcTimeZonePrivate::systemTimeZoneId() const
|
||||
{
|
||||
return QByteArrayLiteral("UTC");
|
||||
return utcQByteArray();
|
||||
}
|
||||
|
||||
QSet<QByteArray> QUtcTimeZonePrivate::availableTimeZoneIds() const
|
||||
|
@ -154,6 +154,17 @@ public:
|
||||
static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId,
|
||||
QLocale::Country country);
|
||||
|
||||
// returns "UTC" QString and QByteArray
|
||||
static inline QString utcQString() Q_REQUIRED_RESULT
|
||||
{
|
||||
return QStringLiteral("UTC");
|
||||
}
|
||||
|
||||
static inline QByteArray utcQByteArray() Q_REQUIRED_RESULT
|
||||
{
|
||||
return QByteArrayLiteral("UTC");
|
||||
}
|
||||
|
||||
protected:
|
||||
QByteArray m_id;
|
||||
};
|
||||
|
@ -958,7 +958,7 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
|
||||
|
||||
// Give up for now and return UTC
|
||||
if (ianaId.isEmpty())
|
||||
ianaId = QByteArrayLiteral("UTC");
|
||||
ianaId = utcQByteArray();
|
||||
|
||||
return ianaId;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ static QByteArray windowsSystemZoneId()
|
||||
}
|
||||
|
||||
// If we can't determine the current ID use UTC
|
||||
return QByteArrayLiteral("UTC");
|
||||
return QTimeZonePrivate::utcQByteArray();
|
||||
}
|
||||
|
||||
static QDate calculateTransitionLocalDate(const SYSTEMTIME &rule, int year)
|
||||
@ -635,7 +635,7 @@ QByteArray QWinTimeZonePrivate::systemTimeZoneId() const
|
||||
ianaId = windowsIdToDefaultIanaId(windowsId);
|
||||
// If no global default then probably an unknown Windows ID so return UTC
|
||||
if (ianaId.isEmpty())
|
||||
return QByteArrayLiteral("UTC");
|
||||
return utcQByteArray();
|
||||
}
|
||||
return ianaId;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user