]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/chnsecal.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / i18n / chnsecal.cpp
index a60a74f185378ad3418898c092a8c21f2ee0a8e2..a862d06d745d2e0d94401b803cb17bddb55f5ba4 100644 (file)
@@ -51,10 +51,7 @@ static void debug_chnsecal_msg(const char *pat, ...)
 
 
 // --- The cache --
-static icu::UMutex *astroLock() {  // Protects access to gChineseCalendarAstro.
-    static icu::UMutex *m = STATIC_NEW(icu::UMutex);
-    return m;
-}
+static icu::UMutex astroLock;
 static icu::CalendarAstronomer *gChineseCalendarAstro = NULL;
 
 // Lazy Creation & Access synchronized by class CalendarCache with a mutex.
@@ -121,7 +118,7 @@ U_NAMESPACE_BEGIN
 //-------------------------------------------------------------------------
 
 
-Calendar* ChineseCalendar::clone() const {
+ChineseCalendar* ChineseCalendar::clone() const {
     return new ChineseCalendar(*this);
 }
 
@@ -490,7 +487,7 @@ double ChineseCalendar::daysToMillis(double days) const {
         UErrorCode status = U_ZERO_ERROR;
         fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status);
         if (U_SUCCESS(status)) {
-            return millis - (double)(rawOffset + dstOffset);
+               return millis - (double)(rawOffset + dstOffset);
         }
     }
     return millis - (double)CHINA_OFFSET;
@@ -507,7 +504,7 @@ double ChineseCalendar::millisToDays(double millis) const {
         UErrorCode status = U_ZERO_ERROR;
         fZoneAstroCalc->getOffset(millis, FALSE, rawOffset, dstOffset, status);
         if (U_SUCCESS(status)) {
-            return ClockMath::floorDivide(millis + (double)(rawOffset + dstOffset), kOneDay);
+               return ClockMath::floorDivide(millis + (double)(rawOffset + dstOffset), kOneDay);
         }
     }
     return ClockMath::floorDivide(millis + (double)CHINA_OFFSET, kOneDay);
@@ -568,14 +565,14 @@ int32_t ChineseCalendar::winterSolstice(int32_t gyear) const {
         // PST 1298 with a final result of Dec 14 10:31:59 PST 1299.
         double ms = daysToMillis(Grego::fieldsToDay(gyear, UCAL_DECEMBER, 1));
 
-        umtx_lock(astroLock());
+        umtx_lock(&astroLock);
         if(gChineseCalendarAstro == NULL) {
             gChineseCalendarAstro = new CalendarAstronomer();
             ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
         }
         gChineseCalendarAstro->setTime(ms);
         UDate solarLong = gChineseCalendarAstro->getSunTime(CalendarAstronomer::WINTER_SOLSTICE(), TRUE);
-        umtx_unlock(astroLock());
+        umtx_unlock(&astroLock);
 
         // Winter solstice is 270 degrees solar longitude aka Dongzhi
         cacheValue = (int32_t)millisToDays(solarLong);
@@ -605,14 +602,14 @@ int32_t ChineseCalendar::newMoonNear(double days, UBool after) const {
     // we are out of its range and need to use the full machinery.
     UDate newMoon = CalendarAstronomer::getNewMoonTimeInRange(ms, after);
     if (newMoon == 0.0) {
-        umtx_lock(astroLock());
+        umtx_lock(&astroLock);
         if(gChineseCalendarAstro == NULL) {
             gChineseCalendarAstro = new CalendarAstronomer();
             ucln_i18n_registerCleanup(UCLN_I18N_CHINESE_CALENDAR, calendar_chinese_cleanup);
         }
         gChineseCalendarAstro->setTime(ms);
         newMoon = gChineseCalendarAstro->getMoonTime(CalendarAstronomer::NEW_MOON(), after);
-        umtx_unlock(astroLock());
+        umtx_unlock(&astroLock);
     }
 
     return (int32_t) millisToDays(newMoon);