diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-01-28 11:23:55 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-01-30 14:18:36 +0000 |
commit | 2e4db2596a69fe9efd0d72a4da7d588716ad2a59 (patch) | |
tree | 6342370a25fbc7bb8dfbe822cc7f2318994b51a5 /tests/auto/testlib/selftests | |
parent | 9135531c33551e03ef2b7287830228def0a81f5a (diff) |
QCalendar: port registry from QHash to QFlatMap
Unlike many other uses of QFlatMap, this actually promises to hit the
QFlatMap sweet spot, and we're using all its levers.
To wit:
- Enable lookup via QAnyStringView through a transparent comparator
without having to convert the QAnyStringView to QString first. This
is impossible with QHash, because qHash() values are not consistent
for different string types: u"a"_qsv == "a"_L1, but qHash(u"a"_qsv)
!= qHash("a"_L1). The relational operators don't have this
consistency problem, and they also implement case-insensitive
comparison, another thing qHash lacks.
- Pick different types of containers for keys and values. For the
keys, use QStringList, which makes availableCalendars() trivial and
extremely fast. We can reserve() the flat_map to limit the effect of
reallocations, because we have a pretty good idea about how many
entries we'll have. For the values, use the same container as for
byID. This might be better with QVarLengthArray, but that's for
another patch.
- Fix the double lookup in registerBackendLockHeld() by using
try_emplace() instead of contains() + insert().
To enable QFlatMap's full potential, we still need to teach
ensurePopulated() to create the two containers for the QFlatMap
unordered and let QFlatMap sort them in one go, but that, too, is for
another patch.
Change-Id: I7fe4f3f7596e9b234696fbc8e467128b85629f8a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/testlib/selftests')
0 files changed, 0 insertions, 0 deletions