mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8304976: Optimize DateTimeFormatterBuilder.ZoneTextPrinterParser.getTree()
Reviewed-by: naoto
This commit is contained in:
parent
d063b8964f
commit
438c969b7b
2 changed files with 61 additions and 5 deletions
|
@ -4516,9 +4516,9 @@ public final class DateTimeFormatterBuilder {
|
|||
|
||||
// cache per instance for now
|
||||
private final Map<Locale, Entry<Integer, SoftReference<PrefixTree>>>
|
||||
cachedTree = new HashMap<>();
|
||||
cachedTree = HashMap.newHashMap(1);
|
||||
private final Map<Locale, Entry<Integer, SoftReference<PrefixTree>>>
|
||||
cachedTreeCI = new HashMap<>();
|
||||
cachedTreeCI = HashMap.newHashMap(1);
|
||||
|
||||
@Override
|
||||
protected PrefixTree getTree(DateTimeParseContext context) {
|
||||
|
@ -4527,9 +4527,8 @@ public final class DateTimeFormatterBuilder {
|
|||
}
|
||||
Locale locale = context.getLocale();
|
||||
boolean isCaseSensitive = context.isCaseSensitive();
|
||||
Set<String> regionIds = new HashSet<>(ZoneRulesProvider.getAvailableZoneIds());
|
||||
Set<String> nonRegionIds = new HashSet<>(64);
|
||||
int regionIdsSize = regionIds.size();
|
||||
Set<String> availableZoneIds = ZoneRulesProvider.getAvailableZoneIds();
|
||||
int regionIdsSize = availableZoneIds.size();
|
||||
|
||||
Map<Locale, Entry<Integer, SoftReference<PrefixTree>>> cached =
|
||||
isCaseSensitive ? cachedTree : cachedTreeCI;
|
||||
|
@ -4542,6 +4541,8 @@ public final class DateTimeFormatterBuilder {
|
|||
(tree = entry.getValue().get()) == null)) {
|
||||
tree = PrefixTree.newTree(context);
|
||||
zoneStrings = TimeZoneNameUtility.getZoneStrings(locale);
|
||||
Set<String> nonRegionIds = HashSet.newHashSet(64);
|
||||
Set<String> regionIds = new HashSet<>(availableZoneIds);
|
||||
for (String[] names : zoneStrings) {
|
||||
String zid = names[0];
|
||||
if (!regionIds.remove(zid)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue