When parsing date/time strings, DateTimeFormatter creates HashMaps to store
intermediate parsed values. HashMap has more overhead for operations compared
to specialized map implementations.
Since ChronoField is an enum and all keys in these maps are ChronoField
instances, we can use EnumMap instead, which provides better performance for
enum keys due to its optimized internal structure.
Parsing scenarios show improvements from 12% to 95%.
To better express my ideas, I submitted a draft PR:
https://github.com/openjdk/jdk/pull/28471
<https://github.com/openjdk/jdk/pull/28471 > , and I hope you can give me
feedback.
-
Shaojin Wen