diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-10-12 13:12:48 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-11-08 13:01:33 +0100 |
commit | a9e4bf7eef4b4e3a2c765cd0a6df48ed61d49111 (patch) | |
tree | 4b15de2f7625edef91168c0d147016ff0d27a0c9 /util/locale_database/qlocalexml.py | |
parent | 246ba8ca61a19b586de1750d66422f517149622e (diff) |
Implement binary search in QLocale's likely sub-tag lookup
Follow through on a comment from 2012: sort the likely subtag array
(in the CLDR update script) and use bsearch to find entries in it.
This simplifies QLocaleXmlReader.likelyMap() slightly, moving the
detection of last entry to LocaleDataWriter.likelySubtags(), but
requires collecting all likely sub-tag mapping pairs (rather than just
passing them through from read to write via generators) in order to
sort them.
Change-Id: Ieb6875ccde1ddbd475ae68c0766a666ec32b7005
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'util/locale_database/qlocalexml.py')
-rw-r--r-- | util/locale_database/qlocalexml.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/util/locale_database/qlocalexml.py b/util/locale_database/qlocalexml.py index 97b369fde8..e5aadba995 100644 --- a/util/locale_database/qlocalexml.py +++ b/util/locale_database/qlocalexml.py @@ -183,12 +183,11 @@ class QLocaleXmlReader (object): def ids(t): return tuple(x[0] for x in t) - for i, pair in enumerate(self.__likely, 1): + for pair in self.__likely: have = self.__fromNames(pair[0]) give = self.__fromNames(pair[1]) yield ('_'.join(tag(have)), ids(have), - '_'.join(tag(give)), ids(give), - i == len(self.__likely)) + '_'.join(tag(give)), ids(give)) def defaultMap(self): """Map language and script to their default country by ID. |