ICU-770 Don't create a cache. Locale::getAvailableLocales does the same thing as DateFormat::getAvailableLocales

X-SVN-Rev: 5675
This commit is contained in:
George Rhoten 2001-09-01 01:09:38 +00:00
parent 51d69e4def
commit 03fdacc9a5
2 changed files with 4 additions and 62 deletions

View File

@ -26,9 +26,6 @@
// class DateFormat
// *****************************************************************************
int32_t DateFormat::fgLocalesCount;
const Locale* DateFormat::fgLocales = 0;
DateFormat::DateFormat()
: fCalendar(0),
fNumberFormat(0)
@ -231,53 +228,10 @@ DateFormat::create(EStyle timeStyle, EStyle dateStyle, const Locale& locale)
const Locale*
DateFormat::getAvailableLocales(int32_t& count)
{
// return LocaleData.getAvailableLocales("DateTimePatterns");
// We only do this computation once. Thereafter, we keep it in the static
// fgLocalesArray. What we do is iterate over all the locales, and try to
// load a specific resource from them which indicates that they have
// date format data.
if (!fgLocales)
{
// This is going to load all the locale resource bundles into the
// cache!
int32_t localesCount;
const Locale* locales = Locale::getAvailableLocales(localesCount);
Locale* temp = new Locale[localesCount];
int32_t newLocalesCount = 0;
int32_t i;
for (i=0; i<localesCount; ++i)
{
UErrorCode status = U_ZERO_ERROR;
ResourceBundle resource((char *)0, locales[i], status);
resource.get(SimpleDateFormat::fgDateTimePatternsTag, status);
if (U_SUCCESS(status))
{
temp[newLocalesCount++] = locales[i];
}
}
Locale *newLocales = new Locale[newLocalesCount];
for (i=0; i<newLocalesCount; ++i) ((Locale*)newLocales)[i] = temp[i]; // Cast away const
delete[] temp;
Mutex lock;
if(!fgLocales)
{
fgLocalesCount = newLocalesCount;
fgLocales = newLocales;
}
else
{
delete [] newLocales; // *shrug*
}
}
count = fgLocalesCount;
return fgLocales;
// Get the list of installed locales.
// Even if root has the correct date format for this locale,
// it's still a valid locale (we don't worry about data fallbacks).
return Locale::getAvailableLocales(count);
}
//----------------------------------------------------------------------

View File

@ -568,18 +568,6 @@ private:
* @return a date/time formatter, or 0 on failure.
*/
static DateFormat* create(EStyle timeStyle, EStyle dateStyle, const Locale&);
/**
* fgLocales and fgLocalesCount cache the available locales array that is returned
* by getAvailableLocales().
*/
static int32_t fgLocalesCount;
/**
* fgLocales and fgLocalesCount cache the available locales array that is returned
* by getAvailableLocales().
*/
static const Locale* fgLocales;
};
inline UnicodeString&