From 01cbd7e4b5ef841c9e091f54cb7ffa6bb059ac31 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 22 Apr 2013 08:35:23 +0200 Subject: Remove QLocalePrivate::m_localeID It was only used for toUpper/toLower but always computed in the constructor, including QString::toLatin1 conversion and allocations. This needlessly slows down all other uses, including supposedly "cheap" operations QString::toDouble, or accesses inside QResourceFileEngine. The benchmarks indicates that doing it always when needed is bearable. There's still a lot of improvement potential on these code paths. Change-Id: I88b637ee11f9f7ea614f8da4ec5df0bf40664fce Reviewed-by: Konstantin Ritt --- src/corelib/tools/qlocale_p.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/corelib/tools/qlocale_p.h') diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 4c0432bba7..9674342307 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -151,7 +151,7 @@ struct QLocaleId QLocaleId withLikelySubtagsAdded() const; QLocaleId withLikelySubtagsRemoved() const; - QString bcp47Name() const; + QByteArray name(char separator = '-') const; ushort language_id, script_id, country_id; }; @@ -212,8 +212,6 @@ public: : m_index(index), m_numberOptions(numberOptions) { m_data = dataPointerForIndex(index); - m_localeID = bcp47Name().toLatin1(); - m_localeID.replace('-','_'); } ~QLocalePrivate() @@ -232,7 +230,7 @@ public: quint16 languageId() const { return m_data->m_language_id; } quint16 countryId() const { return m_data->m_country_id; } - QString bcp47Name() const; + QByteArray bcp47Name(char separator = '-') const; // ### QByteArray::fromRawData would be more optimal inline QString languageCode() const { return QLocalePrivate::languageToCode(QLocale::Language(m_data->m_language_id)); } @@ -334,11 +332,9 @@ public: QString dateTimeToString(const QString &format, const QDate *date, const QTime *time, const QLocale *q) const; - friend class QLocale; quint16 m_index; quint16 m_numberOptions; const QLocaleData *m_data; - QByteArray m_localeID; }; inline char QLocalePrivate::digitToCLocale(QChar in) const -- cgit v1.2.3