Make QMacTimeZonePrivate default constructor more efficient
Inline systemTimeZoneId() in it to save the need for init(). We thus save the lookup by name for a time-zone object, when that object is what we took the name from anyway. Do some minor tidy-up in the other constructors and add an assert to systemTimeZoneId() to match the new one in the default constructor. Change-Id: Ib70acf31bdb4a4fa1306eebd1fd5f00ad6b89bcc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
9f79ab360f
commit
deb166a5ff
@ -60,22 +60,24 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
// Create the system default time zone
|
||||
QMacTimeZonePrivate::QMacTimeZonePrivate()
|
||||
: m_nstz(0)
|
||||
{
|
||||
init(systemTimeZoneId());
|
||||
// Reset the cached system tz then instantiate it:
|
||||
[NSTimeZone resetSystemTimeZone];
|
||||
m_nstz = [NSTimeZone.systemTimeZone retain];
|
||||
Q_ASSERT(m_nstz);
|
||||
m_id = QString::fromNSString(m_nstz.name).toUtf8();
|
||||
}
|
||||
|
||||
// Create a named time zone
|
||||
QMacTimeZonePrivate::QMacTimeZonePrivate(const QByteArray &ianaId)
|
||||
: m_nstz(0)
|
||||
: m_nstz(nil)
|
||||
{
|
||||
init(ianaId);
|
||||
}
|
||||
|
||||
QMacTimeZonePrivate::QMacTimeZonePrivate(const QMacTimeZonePrivate &other)
|
||||
: QTimeZonePrivate(other), m_nstz(0)
|
||||
: QTimeZonePrivate(other), m_nstz([other.m_nstz copy])
|
||||
{
|
||||
m_nstz = [other.m_nstz copy];
|
||||
}
|
||||
|
||||
QMacTimeZonePrivate::~QMacTimeZonePrivate()
|
||||
@ -316,6 +318,7 @@ QByteArray QMacTimeZonePrivate::systemTimeZoneId() const
|
||||
{
|
||||
// Reset the cached system tz then return the name
|
||||
[NSTimeZone resetSystemTimeZone];
|
||||
Q_ASSERT(NSTimeZone.systemTimeZone);
|
||||
return QString::fromNSString([[NSTimeZone systemTimeZone] name]).toUtf8();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user