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,31 +549,33 @@ DateFormatSymbols::getData(ResourceBundle &rb, const char *tag, const char *type
|
||||
char tmp[100];
|
||||
char *fullTag = tmp;
|
||||
|
||||
if(!type || !*type) {
|
||||
type = "gregorian";
|
||||
}
|
||||
|
||||
int32_t len = uprv_strlen(tag) + 1 + uprv_strlen(type); // tag + _ + type (i.e. Eras_Japanese )
|
||||
if(len >= (int32_t)sizeof(tmp)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
uprv_strcpy(fullTag, tag);
|
||||
uprv_strcat(fullTag, "_");
|
||||
uprv_strcat(fullTag, type);
|
||||
uprv_strcpy(fullTag, tag);
|
||||
uprv_strcat(fullTag, "_");
|
||||
uprv_strcat(fullTag, type);
|
||||
|
||||
ResourceBundle resource = rb.get(fullTag, status);
|
||||
ResourceBundle resource = rb.get(fullTag, status);
|
||||
|
||||
if(status == U_MISSING_RESOURCE_ERROR) {
|
||||
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);
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user