diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-08-03 17:19:23 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-08-04 22:22:20 +0200 |
commit | 02aa2362560f1b458b9eaa2f8ba3f27362d0f3ea (patch) | |
tree | 16767fc524030a533f28dfe872f098b420a65990 /src/plugins/platforms/ios/uistrings_p.h | |
parent | 826e1963e3f3a821f31c2457242c4055f9820b0e (diff) |
QMetaTypeFunctionRegistry: avoid double-lookup in insertIfNotContains()
Because there's no insertIfNotContains()-like functionality in QHash
(unlike std::unordered_map, where insert() doesn't overwrite an
existing entry), the code first called contains(k) and then insert(k,
~~~), causing two lookups in the case where the insertion actually
happens.
Fix by using the pattern QDuplicateTracker's QSet fall-back uses, too:
recording the size before and after the call to the indexing operator
and using a size increase as the criterion that an insertion should
happen. This reduces the number of lookups to one, at the cost of a
mapped_type default construction (which, given mapped_type is
std::function, should be cheap).
Change-Id: I24b31107b3e26f2eea2edce7b46f8cb5e7cb35bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/uistrings_p.h')
0 files changed, 0 insertions, 0 deletions