-UnicodeString&
-TimeZoneFormat::parseShortZoneID(const UnicodeString& text, ParsePosition& pos, UnicodeString& tzID) const {
- UErrorCode status = U_ZERO_ERROR;
- UBool initialized;
- UMTX_CHECK(&gLock, gShortZoneIdTrieInitialized, initialized);
- if (!initialized) {
- umtx_lock(&gLock);
- {
- if (!gShortZoneIdTrieInitialized) {
- StringEnumeration *tzenum = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
- if (U_SUCCESS(status)) {
- TextTrieMap* trie = new TextTrieMap(TRUE, NULL); // No deleter, because values are pooled by ZoneMeta
- if (trie) {
- const UnicodeString *id;
- while ((id = tzenum->snext(status))) {
- const UChar* uID = ZoneMeta::findTimeZoneID(*id);
- const UChar* shortID = ZoneMeta::getShortID(*id);
- if (shortID && uID) {
- trie->put(shortID, const_cast<UChar *>(uID), status);
- }
- }
- if (U_SUCCESS(status)) {
- gShortZoneIdTrie = trie;
- gShortZoneIdTrieInitialized = initialized = TRUE;
- ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONEFORMAT, tzfmt_cleanup);
- } else {
- delete trie;
- }
- }
+static void U_CALLCONV initShortZoneIdTrie(UErrorCode &status) {
+ U_ASSERT(gShortZoneIdTrie == NULL);
+ ucln_i18n_registerCleanup(UCLN_I18N_TIMEZONEFORMAT, tzfmt_cleanup);
+ StringEnumeration *tzenum = TimeZone::createTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, NULL, NULL, status);
+ if (U_SUCCESS(status)) {
+ gShortZoneIdTrie = new TextTrieMap(TRUE, NULL); // No deleter, because values are pooled by ZoneMeta
+ if (gShortZoneIdTrie == NULL) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ } else {
+ const UnicodeString *id;
+ while ((id = tzenum->snext(status)) != NULL) {
+ const UChar* uID = ZoneMeta::findTimeZoneID(*id);
+ const UChar* shortID = ZoneMeta::getShortID(*id);
+ if (shortID && uID) {
+ gShortZoneIdTrie->put(shortID, const_cast<UChar *>(uID), status);