8283324: CLDRConverter run time increased by 3x

Reviewed-by: ihse
This commit is contained in:
Naoto Sato 2022-04-21 22:23:24 +00:00
parent ec4fb47b90
commit f6e9ca0cbe
2 changed files with 16 additions and 6 deletions

View File

@ -847,19 +847,24 @@ public class CLDRConverter {
"DateTimePatternChars",
"PluralRules",
"DayPeriodRules",
"DateFormatItem",
"DateFormatItemInputRegions.allowed",
"DateFormatItemInputRegions.preferred",
};
static final Set<String> availableSkeletons = new HashSet<>();
private static Map<String, Object> extractFormatData(Map<String, Object> map, String id) {
Map<String, Object> formatData = new LinkedHashMap<>();
for (CalendarType calendarType : CalendarType.values()) {
String prefix = calendarType.keyElementName();
Arrays.stream(FORMAT_DATA_ELEMENTS)
.flatMap(elem -> map.keySet().stream().filter(k -> k.startsWith(prefix + elem)))
.forEach(key -> {
.forEach(elem -> {
var key = prefix + elem;
copyIfPresent(map, "java.time." + key, formatData);
copyIfPresent(map, key, formatData);
});
availableSkeletons.forEach(s ->
copyIfPresent(map, prefix + "DateFormatItem." + s, formatData));
}
for (String key : map.keySet()) {

View File

@ -768,9 +768,14 @@ class LDMLParseHandler extends AbstractLDMLHandler<Object> {
case "dateFormatItem":
{
// for FormatData
prefix = (currentCalendarType == null) ? "" : currentCalendarType.keyElementName();
pushStringEntry(qName, attributes,
prefix + Bundle.DATEFORMATITEM_KEY_PREFIX + attributes.getValue("id"));
if (currentCalendarType != null) {
var skeleton = attributes.getValue("id");
CLDRConverter.availableSkeletons.add(skeleton);
pushStringEntry(qName, attributes,
currentCalendarType.keyElementName() + Bundle.DATEFORMATITEM_KEY_PREFIX + skeleton);
} else {
pushIgnoredContainer(qName);
}
}
break;