QLocalePrivate: remove QLocalePrivate::m_index
It's not used anywhere, so we don't need to cache the locale data index. We already have the pointer to the QLocaleData anyway. This saves us a few roundtrips calculating the index from the data pointer only to get the data pointer again. Change-Id: I6905d20a382ddcb9fb04cc886a17499b467f905a Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
This commit is contained in:
parent
600c538cd6
commit
50ab31a5df
@ -699,45 +699,30 @@ const QLocaleData *QLocalePrivate::dataPointerForIndex(quint16 index)
|
||||
return &locale_data[index];
|
||||
}
|
||||
|
||||
static quint16 localeDataIndex(const QLocaleData *p)
|
||||
{
|
||||
#ifndef QT_NO_SYSTEMLOCALE
|
||||
Q_ASSERT((p >= locale_data && p - locale_data < locale_data_size)
|
||||
|| (p != 0 && p == system_data));
|
||||
quint16 index = p == system_data ? locale_data_size : p - locale_data;
|
||||
#else
|
||||
Q_ASSERT(p >= locale_data && p - locale_data < locale_data_size);
|
||||
quint16 index = p - locale_data;
|
||||
#endif
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
static QLocalePrivate *localePrivateByName(const QString &name)
|
||||
{
|
||||
return new QLocalePrivate(localeDataIndex(findLocaleData(name)));
|
||||
return new QLocalePrivate(findLocaleData(name));
|
||||
}
|
||||
|
||||
static QLocalePrivate *defaultLocalePrivate()
|
||||
{
|
||||
return new QLocalePrivate(localeDataIndex(defaultData()), default_number_options);
|
||||
return new QLocalePrivate(defaultData(), default_number_options);
|
||||
}
|
||||
|
||||
static QLocalePrivate *findLocalePrivate(QLocale::Language language, QLocale::Script script,
|
||||
QLocale::Country country)
|
||||
{
|
||||
const QLocaleData *data = QLocaleData::findLocaleData(language, script, country);
|
||||
int index;
|
||||
|
||||
int numberOptions = 0;
|
||||
|
||||
// If not found, should default to system
|
||||
if (data->m_language_id == QLocale::C && language != QLocale::C) {
|
||||
numberOptions = default_number_options;
|
||||
index = localeDataIndex(defaultData());
|
||||
} else {
|
||||
index = localeDataIndex(data);
|
||||
data = defaultData();
|
||||
}
|
||||
return new QLocalePrivate(index, numberOptions);
|
||||
return new QLocalePrivate(data, numberOptions);
|
||||
}
|
||||
|
||||
|
||||
@ -2123,7 +2108,7 @@ QString QLocale::toString(double i, char f, int prec) const
|
||||
|
||||
QLocale QLocale::system()
|
||||
{
|
||||
return QLocale(*new QLocalePrivate(localeDataIndex(systemData())));
|
||||
return QLocale(*new QLocalePrivate(systemData()));
|
||||
}
|
||||
|
||||
|
||||
@ -2158,7 +2143,7 @@ QList<QLocale> QLocale::matchingLocales(QLocale::Language language,
|
||||
&& (language == QLocale::AnyLanguage || data->m_language_id == uint(language))) {
|
||||
if ((script == QLocale::AnyScript || data->m_script_id == uint(script))
|
||||
&& (country == QLocale::AnyCountry || data->m_country_id == uint(country))) {
|
||||
QLocale locale(*new QLocalePrivate(localeDataIndex(data)));
|
||||
QLocale locale(*new QLocalePrivate(data));
|
||||
result.append(locale);
|
||||
}
|
||||
++data;
|
||||
|
@ -208,10 +208,9 @@ public:
|
||||
class Q_CORE_EXPORT QLocalePrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
explicit QLocalePrivate(int index, int numberOptions = 0)
|
||||
: m_index(index), m_numberOptions(numberOptions)
|
||||
explicit QLocalePrivate(const QLocaleData *data, int numberOptions = 0)
|
||||
: m_data(data), m_numberOptions(numberOptions)
|
||||
{
|
||||
m_data = dataPointerForIndex(index);
|
||||
}
|
||||
|
||||
~QLocalePrivate()
|
||||
@ -332,9 +331,8 @@ public:
|
||||
QString dateTimeToString(const QString &format, const QDate *date, const QTime *time,
|
||||
const QLocale *q) const;
|
||||
|
||||
quint16 m_index;
|
||||
quint16 m_numberOptions;
|
||||
const QLocaleData *m_data;
|
||||
quint16 m_numberOptions;
|
||||
};
|
||||
|
||||
inline char QLocalePrivate::digitToCLocale(QChar in) const
|
||||
|
Loading…
Reference in New Issue
Block a user