ICU-2704 Use a smaller and faster way to get the list of available locales.
X-SVN-Rev: 11147
This commit is contained in:
parent
493644061a
commit
67725ff09d
@ -1295,19 +1295,13 @@ uloc_countAvailable()
|
||||
|
||||
UBool uloc_cleanup(void) {
|
||||
char ** temp;
|
||||
int32_t localeCount;
|
||||
int32_t i;
|
||||
|
||||
if (_installedLocales) {
|
||||
temp = _installedLocales;
|
||||
_installedLocales = NULL;
|
||||
|
||||
localeCount = _installedLocalesCount;
|
||||
_installedLocalesCount = 0;
|
||||
|
||||
for (i = 0; i < localeCount; i++) {
|
||||
uprv_free(temp[i]);
|
||||
}
|
||||
uprv_free(temp);
|
||||
}
|
||||
return TRUE;
|
||||
@ -1318,10 +1312,8 @@ static void _lazyEvaluate_installedLocales()
|
||||
UResourceBundle *index = NULL;
|
||||
UResourceBundle installed;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
const UChar *lname;
|
||||
char ** temp;
|
||||
int32_t i = 0;
|
||||
int32_t len = 0;
|
||||
int32_t localeCount;
|
||||
|
||||
ures_initStackObject(&installed);
|
||||
@ -1334,13 +1326,9 @@ static void _lazyEvaluate_installedLocales()
|
||||
|
||||
ures_resetIterator(&installed);
|
||||
while(ures_hasNext(&installed)) {
|
||||
lname = ures_getNextString(&installed, &len, NULL, &status);
|
||||
temp[i] = (char*) uprv_malloc(sizeof(char) * (len + 1));
|
||||
|
||||
u_UCharsToChars(lname, temp[i], len);
|
||||
temp[i][len] = 0; /* Terminate the string */
|
||||
i++;
|
||||
ures_getNextString(&installed, NULL, &temp[i++], &status);
|
||||
}
|
||||
temp[i] = NULL;
|
||||
|
||||
umtx_lock(NULL);
|
||||
if (_installedLocales == NULL)
|
||||
@ -1348,9 +1336,6 @@ static void _lazyEvaluate_installedLocales()
|
||||
_installedLocales = temp;
|
||||
_installedLocalesCount = localeCount;
|
||||
} else {
|
||||
for (i = 0; i < localeCount; i++) {
|
||||
uprv_free(temp[i]);
|
||||
}
|
||||
uprv_free(temp);
|
||||
}
|
||||
umtx_unlock(NULL);
|
||||
|
@ -146,7 +146,7 @@ include $(LOCSRCDIR)/resfiles.mk
|
||||
-include $(LOCSRCDIR)/reslocal.mk
|
||||
RES_SOURCE= root.txt $(GENRB_SOURCE) $(GENRB_ALIAS_SOURCE) $(GENRB_SOURCE_LOCAL)
|
||||
RES_SRC_FILES = $(RES_SOURCE:%=$(LOCSRCDIR)/%)
|
||||
INSTALLED_RB_FILES = $(GENRB_SOURCE:%.txt=%,) $(GENRB_SOURCE_LOCAL:%.txt=%,)
|
||||
INSTALLED_RB_FILES = $(GENRB_SOURCE:%.txt=%) $(GENRB_SOURCE_LOCAL:%.txt=%)
|
||||
GENRBOPTS=-k -q
|
||||
|
||||
## TRNS files
|
||||
@ -248,9 +248,9 @@ $(BUILDDIR)/res_index.txt: $(SRCLISTDEPS)
|
||||
$(RMV) $@; \
|
||||
echo "// Warning this file is automatically generated" > $@; \
|
||||
echo "res_index {" >> $@; \
|
||||
echo " InstalledLocales:array {" >> $@; \
|
||||
echo " InstalledLocales {" >> $@; \
|
||||
for file in $(INSTALLED_RB_FILES); do \
|
||||
echo " $$file" >> $@; \
|
||||
echo " $$file {\"\"}" >> $@; \
|
||||
done; \
|
||||
echo " }" >> $@; \
|
||||
echo "}" >> $@;
|
||||
|
@ -192,9 +192,6 @@ GENRB_SOURCE=$(GENRB_SOURCE) $(GENRB_SOURCE_LOCAL)
|
||||
|
||||
RB_FILES = root.res $(GENRB_ALIAS_SOURCE:.txt=.res) $(GENRB_SOURCE:.txt=.res)
|
||||
|
||||
# The installed locales don't have aliased locales
|
||||
INSTALLED_RB_FILES = $(GENRB_SOURCE:.txt=,)
|
||||
|
||||
# Read list of transliterator resource bundle files
|
||||
!IF EXISTS("$(ICUSRCDATA)\$(ICUTRNS)\trnsfiles.mk")
|
||||
!INCLUDE "$(ICUSRCDATA)\$(ICUTRNS)\trnsfiles.mk"
|
||||
@ -347,9 +344,9 @@ CLEAN : GODATA
|
||||
@echo Generating <<res_index.txt
|
||||
// Warning this file is automatically generated
|
||||
res_index {
|
||||
InstalledLocales:array {
|
||||
$(INSTALLED_RB_FILES:, =,
|
||||
)
|
||||
InstalledLocales {
|
||||
$(GENRB_SOURCE:.txt= {""}
|
||||
)
|
||||
}
|
||||
}
|
||||
<<KEEP
|
||||
|
Loading…
Reference in New Issue
Block a user