ICU-2943 optimise Gregorian symbol lookup (never check ex. "Eras_gregorian")
X-SVN-Rev: 12654
This commit is contained in:
parent
6893e0e031
commit
7656836ef9
@ -549,10 +549,7 @@ DateFormatSymbols::getData(ResourceBundle &rb, const char *tag, const char *type
|
||||
char tmp[100];
|
||||
char *fullTag = tmp;
|
||||
|
||||
if(!type || !*type) {
|
||||
type = "gregorian";
|
||||
}
|
||||
|
||||
if(type && uprv_strcmp(type, "gregorian") && *type) {
|
||||
int32_t len = uprv_strlen(tag) + 1 + uprv_strlen(type); // tag + _ + type (i.e. Eras_Japanese )
|
||||
if(len >= (int32_t)sizeof(tmp)) {
|
||||
fullTag = (char*)uprv_malloc(len+1);
|
||||
@ -564,16 +561,21 @@ DateFormatSymbols::getData(ResourceBundle &rb, const char *tag, const char *type
|
||||
|
||||
ResourceBundle resource = rb.get(fullTag, status);
|
||||
|
||||
if(fullTag != tmp) {
|
||||
uprv_free(fullTag); // not stack allocated
|
||||
}
|
||||
|
||||
// fallback if not found
|
||||
if(status == U_MISSING_RESOURCE_ERROR) {
|
||||
status = U_ZERO_ERROR;
|
||||
resource = rb.get(tag, status);
|
||||
}
|
||||
|
||||
if(fullTag != tmp) {
|
||||
uprv_free(fullTag); // not stack allocated
|
||||
}
|
||||
|
||||
return resource;
|
||||
} else {
|
||||
// Gregorian case
|
||||
return rb.get(tag, status);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user