Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: source/i18n/tznames.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/tzgnames.cpp ('k') | source/i18n/ucal.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************* 2 *******************************************************************************
3 * Copyright (C) 2011-2014, International Business Machines Corporation and * 3 * Copyright (C) 2011-2015, International Business Machines Corporation and *
4 * others. All Rights Reserved. * 4 * others. All Rights Reserved. *
5 ******************************************************************************* 5 *******************************************************************************
6 */ 6 */
7 7
8 #include "unicode/utypes.h" 8 #include "unicode/utypes.h"
9 9
10 #if !UCONFIG_NO_FORMATTING 10 #if !UCONFIG_NO_FORMATTING
11 11
12 #include "unicode/locid.h" 12 #include "unicode/locid.h"
13 #include "unicode/tznames.h" 13 #include "unicode/tznames.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 uprv_free(entry); 74 uprv_free(entry);
75 } 75 }
76 U_CDECL_END 76 U_CDECL_END
77 77
78 /** 78 /**
79 * Function used for removing unreferrenced cache entries exceeding 79 * Function used for removing unreferrenced cache entries exceeding
80 * the expiration time. This function must be called with in the mutex 80 * the expiration time. This function must be called with in the mutex
81 * block. 81 * block.
82 */ 82 */
83 static void sweepCache() { 83 static void sweepCache() {
84 int32_t pos = -1; 84 int32_t pos = UHASH_FIRST;
85 const UHashElement* elem; 85 const UHashElement* elem;
86 double now = (double)uprv_getUTCtime(); 86 double now = (double)uprv_getUTCtime();
87 87
88 while ((elem = uhash_nextElement(gTimeZoneNamesCache, &pos))) { 88 while ((elem = uhash_nextElement(gTimeZoneNamesCache, &pos))) {
89 TimeZoneNamesCacheEntry *entry = (TimeZoneNamesCacheEntry *)elem->value. pointer; 89 TimeZoneNamesCacheEntry *entry = (TimeZoneNamesCacheEntry *)elem->value. pointer;
90 if (entry->refCount <= 0 && (now - entry->lastAccess) > CACHE_EXPIRATION ) { 90 if (entry->refCount <= 0 && (now - entry->lastAccess) > CACHE_EXPIRATION ) {
91 // delete this entry 91 // delete this entry
92 uhash_removeElement(gTimeZoneNamesCache, elem); 92 uhash_removeElement(gTimeZoneNamesCache, elem);
93 } 93 }
94 } 94 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 TimeZoneNames *instance = NULL; 294 TimeZoneNames *instance = NULL;
295 if (U_SUCCESS(status)) { 295 if (U_SUCCESS(status)) {
296 instance = new TimeZoneNamesDelegate(locale, status); 296 instance = new TimeZoneNamesDelegate(locale, status);
297 if (instance == NULL && U_SUCCESS(status)) { 297 if (instance == NULL && U_SUCCESS(status)) {
298 status = U_MEMORY_ALLOCATION_ERROR; 298 status = U_MEMORY_ALLOCATION_ERROR;
299 } 299 }
300 } 300 }
301 return instance; 301 return instance;
302 } 302 }
303 303
304 #ifndef U_HIDE_DRAFT_API
305 TimeZoneNames* 304 TimeZoneNames*
306 TimeZoneNames::createTZDBInstance(const Locale& locale, UErrorCode& status) { 305 TimeZoneNames::createTZDBInstance(const Locale& locale, UErrorCode& status) {
307 TimeZoneNames *instance = NULL; 306 TimeZoneNames *instance = NULL;
308 if (U_SUCCESS(status)) { 307 if (U_SUCCESS(status)) {
309 instance = new TZDBTimeZoneNames(locale); 308 instance = new TZDBTimeZoneNames(locale);
310 if (instance == NULL && U_SUCCESS(status)) { 309 if (instance == NULL && U_SUCCESS(status)) {
311 status = U_MEMORY_ALLOCATION_ERROR; 310 status = U_MEMORY_ALLOCATION_ERROR;
312 } 311 }
313 } 312 }
314 return instance; 313 return instance;
315 } 314 }
316 #endif /* U_HIDE_DRAFT_API */
317 315
318 UnicodeString& 316 UnicodeString&
319 TimeZoneNames::getExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) const { 317 TimeZoneNames::getExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) const {
320 return TimeZoneNamesImpl::getDefaultExemplarLocationName(tzID, name); 318 return TimeZoneNamesImpl::getDefaultExemplarLocationName(tzID, name);
321 } 319 }
322 320
323 UnicodeString& 321 UnicodeString&
324 TimeZoneNames::getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const { 322 TimeZoneNames::getDisplayName(const UnicodeString& tzID, UTimeZoneNameType type, UDate date, UnicodeString& name) const {
325 getTimeZoneDisplayName(tzID, type, name); 323 getTimeZoneDisplayName(tzID, type, name);
326 if (name.isEmpty()) { 324 if (name.isEmpty()) {
327 UnicodeString mzID; 325 UChar mzIDBuf[32];
326 UnicodeString mzID(mzIDBuf, 0, UPRV_LENGTHOF(mzIDBuf));
328 getMetaZoneID(tzID, date, mzID); 327 getMetaZoneID(tzID, date, mzID);
329 getMetaZoneDisplayName(mzID, type, name); 328 getMetaZoneDisplayName(mzID, type, name);
330 } 329 }
331 return name; 330 return name;
332 } 331 }
333 332
334 333
335 struct MatchInfo : UMemory { 334 struct MatchInfo : UMemory {
336 UTimeZoneNameType nameType; 335 UTimeZoneNameType nameType;
337 UnicodeString id; 336 UnicodeString id;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } else if (U_FAILURE(status)) { 466 } else if (U_FAILURE(status)) {
468 delete fMatches; 467 delete fMatches;
469 fMatches = NULL; 468 fMatches = NULL;
470 } 469 }
471 return fMatches; 470 return fMatches;
472 } 471 }
473 472
474 473
475 U_NAMESPACE_END 474 U_NAMESPACE_END
476 #endif 475 #endif
OLDNEW
« no previous file with comments | « source/i18n/tzgnames.cpp ('k') | source/i18n/ucal.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698