mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-3837 Reduce the number of mallocs
X-SVN-Rev: 16035
This commit is contained in:
parent
e069f28ece
commit
011fe48d05
2 changed files with 12 additions and 14 deletions
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue