Use QByteArrayView lists of IANA IDs before working out which we have
The QTZP::availableTimeZoneIds() overloads taking a territory or offset to select on were building a list of QBAs, allocating copies of static data to do so, and then taking their intersection with the no-parameter overload. Since the latter is of QBAs and the intersection code used its begin() and end() for the first pair of parameters to std::intersection(), from which the results are drawn, we can use a QBAV list for the second pair of parameters (with whose range the first pair's range is intersected), thanks to QBAV entries in the list being comparable with QBA. This saves allocating copies of the static data, when we can make do with simply building a list of views of that data. Belatedly picking to 6.8 as a prerequisite of a later change. Change-Id: I42de4a91273e23fb394f9ae7a86f7f3fadf95be3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 67fb5dcfcd1bac5d5b30723a4ebba84acda58902) Reviewed-by: Mate Barany <mate.barany@qt.io>
This commit is contained in:
parent
f60fd291b5
commit
abf8d5a671
@ -613,7 +613,8 @@ QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds() const
|
|||||||
return QList<QByteArray>();
|
return QList<QByteArray>();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<QByteArray> selectAvailable(QList<QByteArray>&& desired, const QList<QByteArray>& all)
|
static QList<QByteArray> selectAvailable(QList<QByteArrayView> &&desired,
|
||||||
|
const QList<QByteArray> &all)
|
||||||
{
|
{
|
||||||
std::sort(desired.begin(), desired.end());
|
std::sort(desired.begin(), desired.end());
|
||||||
const auto newEnd = std::unique(desired.begin(), desired.end());
|
const auto newEnd = std::unique(desired.begin(), desired.end());
|
||||||
@ -628,13 +629,13 @@ static QList<QByteArray> selectAvailable(QList<QByteArray>&& desired, const QLis
|
|||||||
QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
|
QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
|
||||||
{
|
{
|
||||||
// Default fall-back mode, use the zoneTable to find Region of know Zones
|
// Default fall-back mode, use the zoneTable to find Region of know Zones
|
||||||
QList<QByteArray> regions;
|
QList<QByteArrayView> regions;
|
||||||
|
|
||||||
// First get all Zones in the Zones table belonging to the Region
|
// First get all Zones in the Zones table belonging to the Region
|
||||||
for (const ZoneData &data : zoneDataTable) {
|
for (const ZoneData &data : zoneDataTable) {
|
||||||
if (data.territory == territory) {
|
if (data.territory == territory) {
|
||||||
for (auto l1 : data.ids())
|
for (auto l1 : data.ids())
|
||||||
regions << QByteArray(l1.data(), l1.size());
|
regions << QByteArrayView(l1.data(), l1.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return selectAvailable(std::move(regions), availableTimeZoneIds());
|
return selectAvailable(std::move(regions), availableTimeZoneIds());
|
||||||
@ -642,16 +643,16 @@ QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(QLocale::Territory terr
|
|||||||
|
|
||||||
QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(int offsetFromUtc) const
|
QList<QByteArray> QTimeZonePrivate::availableTimeZoneIds(int offsetFromUtc) const
|
||||||
{
|
{
|
||||||
// Default fall-back mode, use the zoneTable to find Offset of know Zones
|
// Default fall-back mode: use the zoneTable to find offsets of know zones.
|
||||||
QList<QByteArray> offsets;
|
QList<QByteArrayView> offsets;
|
||||||
// First get all Zones in the table using the Offset
|
// First get all Zones in the table using the given offset:
|
||||||
for (const WindowsData &winData : windowsDataTable) {
|
for (const WindowsData &winData : windowsDataTable) {
|
||||||
if (winData.offsetFromUtc == offsetFromUtc) {
|
if (winData.offsetFromUtc == offsetFromUtc) {
|
||||||
for (auto data = zoneStartForWindowsId(winData.windowsIdKey);
|
for (auto data = zoneStartForWindowsId(winData.windowsIdKey);
|
||||||
data != std::end(zoneDataTable) && data->windowsIdKey == winData.windowsIdKey;
|
data != std::end(zoneDataTable) && data->windowsIdKey == winData.windowsIdKey;
|
||||||
++data) {
|
++data) {
|
||||||
for (auto l1 : data->ids())
|
for (auto l1 : data->ids())
|
||||||
offsets << QByteArray(l1.data(), l1.size());
|
offsets << QByteArrayView(l1.data(), l1.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user