ICU-3837 Reduce the number of mallocs

X-SVN-Rev: 16035
This commit is contained in:
George Rhoten 2004-07-18 02:01:42 +00:00
parent e069f28ece
commit 011fe48d05
2 changed files with 12 additions and 14 deletions

View file

@ -698,19 +698,18 @@ HebrewCalendar::initializeSystemDefaultCentury()
if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury)
{
UErrorCode status = U_ZERO_ERROR;
Calendar *calendar = new HebrewCalendar(Locale("he@calendar=hebrew"),status);
if (calendar != NULL && U_SUCCESS(status))
HebrewCalendar calendar(Locale("he@calendar=hebrew"),status);
if (U_SUCCESS(status))
{
calendar->setTime(Calendar::getNow(), status);
calendar->add(UCAL_YEAR, -80, status);
UDate newStart = calendar->getTime(status);
int32_t newYear = calendar->get(UCAL_YEAR, status);
calendar.setTime(Calendar::getNow(), status);
calendar.add(UCAL_YEAR, -80, status);
UDate newStart = calendar.getTime(status);
int32_t newYear = calendar.get(UCAL_YEAR, status);
{
Mutex m;
fgSystemDefaultCenturyStart = newStart;
fgSystemDefaultCenturyStartYear = newYear;
}
delete calendar;
}
// We have no recourse upon failure unless we want to propagate the failure
// out.

View file

@ -487,19 +487,18 @@ IslamicCalendar::initializeSystemDefaultCentury()
if (fgSystemDefaultCenturyStart == fgSystemDefaultCentury)
{
UErrorCode status = U_ZERO_ERROR;
Calendar *calendar = new IslamicCalendar(Locale("ar@calendar=islamic-civil"),status);
if (calendar != NULL && U_SUCCESS(status))
IslamicCalendar calendar(Locale("ar@calendar=islamic-civil"),status);
if (U_SUCCESS(status))
{
calendar->setTime(Calendar::getNow(), status);
calendar->add(UCAL_YEAR, -80, status);
UDate newStart = calendar->getTime(status);
int32_t newYear = calendar->get(UCAL_YEAR, status);
calendar.setTime(Calendar::getNow(), status);
calendar.add(UCAL_YEAR, -80, status);
UDate newStart = calendar.getTime(status);
int32_t newYear = calendar.get(UCAL_YEAR, status);
{
Mutex m;
fgSystemDefaultCenturyStart = newStart;
fgSystemDefaultCenturyStartYear = newYear;
}
delete calendar;
}
// We have no recourse upon failure unless we want to propagate the failure
// out.