Cache country <-> ISO code mapping in both directions
ClosedPublic

Authored by vkrause on Jul 15 2018, 9:14 AM.

Details

Summary

This is just a stop-gap measure to avoid reloading the entire country map
file for every call (which is a noticeable problem when using this in a
list view delegate on an Android phone).

The real solution would be converting the map into a directly usable
format that we don't need to parse, but before doing that I'd like to
understand how the i18n() call is supposed to work here...

Diff Detail

Repository
R174 KContacts
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
vkrause created this revision.Jul 15 2018, 9:14 AM
Restricted Application added a project: KDE PIM. · View Herald TranscriptJul 15 2018, 9:14 AM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
vkrause requested review of this revision.Jul 15 2018, 9:14 AM
dvratil added inline comments.
src/address.cpp
655

s/QMap/QHash/

672

Would it make sense to also insert the strings to the isoToCountry hash table to benefit QString's explicit sharing (and vice-verase in ISOToCountry()), or is it unlikely any code would benefit from this?

vkrause added inline comments.Jul 15 2018, 12:06 PM
src/address.cpp
672

This could work in ISOtoCountry indeed, but here we would need to check if the language of the country name is the local one before inserting, which we have no way of detecting.

vkrause updated this revision to Diff 37814.Jul 15 2018, 3:53 PM

Address review comments.

dvratil accepted this revision.Jul 15 2018, 9:15 PM
This revision is now accepted and ready to land.Jul 15 2018, 9:15 PM
This revision was automatically updated to reflect the committed changes.