On Tue, 9 Dec 2025 10:02:36 GMT, Shaojin Wen <[email protected]> wrote:
>> This PR optimizes the parsing performance of DateTimeFormatter by replacing >> HashMap with EnumMap in scenarios where the keys are exclusively ChronoField >> enum values. >> >> 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% > > Shaojin Wen has updated the pull request incrementally with one additional > commit since the last revision: > > remove redundant checkField Given early comments about parsing, I'd expect further work to allow queries of the Map testing for the fields needed by common patterns. A specialized Map could use a bitmap/array for the ChronoFields and test for multiple fields at a time. A specialized Map could have a `putChronoField` method that would bypass extra testing on the type, it would be used by the implementation in Parsed maintaining encapsulation. There is an edge case that could be used for an custom implementation of TemporalField in which the `TemporField.resolve` implementation for the new custom field could `put` a new non-ChronoField field into the map. ------------- PR Comment: https://git.openjdk.org/jdk/pull/28471#issuecomment-3682326591
