diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-01-09 14:48:21 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-01-30 17:58:53 +0100 |
commit | c08a31634fd8d25d14aed4a73a80f44f254163f3 (patch) | |
tree | b19cf37f2e7405845f72613bd59911256c19a4dc /src/corelib/time/qcalendarbackend_p.h | |
parent | c0f041fcdf9573c0777fd19a0ce012fedf83fec4 (diff) |
Separate offsets from sizes in QLocale's data
This enables us to make the sizes quint8 and benefit from the
resulting packing, making the locale data smaller. The sizes for long
month-name lists (which concatenate twelve names with semicolon as
separator) can overflow an 8-bit member, so use quint16 where needed.
Re-ordered the data in QLocaleData and QCalendarLocale. Now all
long-short(-narrow) families arise in that order; and any standalone
is grouped with the one of the same length. (This cost 20 bytes in the
date-format table, which optimises out more duplication if short is
before long, but the saving in the (smaller) time-format table more
than make up for it; and 20 bytes isn't worth the confusion that being
inconsistent in ordering might cause.)
At the same time, drop trailing semicolons from list entries (which
join various names with semicolon) as they're not needed: we know
where the end of the list is, because we know the size of the string
that results from concatenation. The code that parses such lists can
even correctly handle empty entries at the end.
Saves 26 kB of data in the compiled binaries.
Task-number: QTBUG-81053
Change-Id: If6ccc96a6910828817aa605d10fd814f567ae1e8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/time/qcalendarbackend_p.h')
-rw-r--r-- | src/corelib/time/qcalendarbackend_p.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/corelib/time/qcalendarbackend_p.h b/src/corelib/time/qcalendarbackend_p.h index 843e42c584..24dd08873d 100644 --- a/src/corelib/time/qcalendarbackend_p.h +++ b/src/corelib/time/qcalendarbackend_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -64,13 +64,25 @@ QT_BEGIN_NAMESPACE struct QCalendarLocale { quint16 m_language_id, m_script_id, m_country_id; + +#define rangeGetter(name) \ + QLocaleData::DataRange name() const { return { m_ ## name ## _idx, m_ ## name ## _size }; } + + rangeGetter(longMonthStandalone) rangeGetter(longMonth) + rangeGetter(shortMonthStandalone) rangeGetter(shortMonth) + rangeGetter(narrowMonthStandalone) rangeGetter(narrowMonth) +#undef rangeGetter + // Month name indexes: - QLocaleData::DataRange m_standalone_short; - QLocaleData::DataRange m_standalone_long; - QLocaleData::DataRange m_standalone_narrow; - QLocaleData::DataRange m_short; - QLocaleData::DataRange m_long; - QLocaleData::DataRange m_narrow; + quint16 m_longMonthStandalone_idx, m_longMonth_idx; + quint16 m_shortMonthStandalone_idx, m_shortMonth_idx; + quint16 m_narrowMonthStandalone_idx, m_narrowMonth_idx; + + // Twelve long month names (separated by commas) can add up to more than 256 + // QChars - e.g. kde_TZ gets to 264. + quint16 m_longMonthStandalone_size, m_longMonth_size; + quint8 m_shortMonthStandalone_size, m_shortMonth_size; + quint8 m_narrowMonthStandalone_size, m_narrowMonth_size; }; // Partial implementation, of methods with common forms, in qcalendar.cpp |