diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2021-04-22 15:08:59 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2021-04-22 16:56:53 +0300 |
commit | b56241f22f96826ef9ef38cf7e4312b899f8e241 (patch) | |
tree | d12402a7b6881fe6f1f8c33228d5b1054c7942f0 /thirdparty/icu4c/common/localeprioritylist.cpp | |
parent | 77a876c6e1c9eb60abbd9ad6f6ba6d9bc0af14e1 (diff) |
ICU: Update to version 69.1, improve ICU data export process.
Diffstat (limited to 'thirdparty/icu4c/common/localeprioritylist.cpp')
-rw-r--r-- | thirdparty/icu4c/common/localeprioritylist.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/thirdparty/icu4c/common/localeprioritylist.cpp b/thirdparty/icu4c/common/localeprioritylist.cpp index 8916b121be..4455eedb75 100644 --- a/thirdparty/icu4c/common/localeprioritylist.cpp +++ b/thirdparty/icu4c/common/localeprioritylist.cpp @@ -187,17 +187,18 @@ bool LocalePriorityList::add(const Locale &locale, int32_t weight, UErrorCode &e if (U_FAILURE(errorCode)) { return false; } } LocalPointer<Locale> clone; - int32_t index = uhash_geti(map, &locale); - if (index != 0) { + UBool found = false; + int32_t index = uhash_getiAndFound(map, &locale, &found); + if (found) { // Duplicate: Remove the old item and append it anew. - LocaleAndWeight &lw = list->array[index - 1]; + LocaleAndWeight &lw = list->array[index]; clone.adoptInstead(lw.locale); lw.locale = nullptr; lw.weight = 0; ++numRemoved; } if (weight <= 0) { // do not add q=0 - if (index != 0) { + if (found) { // Not strictly necessary but cleaner. uhash_removei(map, &locale); } @@ -217,7 +218,7 @@ bool LocalePriorityList::add(const Locale &locale, int32_t weight, UErrorCode &e return false; } } - uhash_puti(map, clone.getAlias(), listLength + 1, &errorCode); + uhash_putiAllowZero(map, clone.getAlias(), listLength, &errorCode); if (U_FAILURE(errorCode)) { return false; } LocaleAndWeight &lw = list->array[listLength]; lw.locale = clone.orphan(); |