RFR: 8372460: Use EnumMap instead of HashMap for DateTimeFormatter parsing to improve performance [v6]
Shaojin Wen
swen at openjdk.org
Tue Dec 9 06:15:41 UTC 2025
> 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:
Revert "resolverFields, from @liach"
This reverts commit b2b19e1368ef9b295876e6b79f8bfb163f3b3f1c.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/28471/files
- new: https://git.openjdk.org/jdk/pull/28471/files/b2b19e13..90dca377
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=28471&range=05
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=28471&range=04-05
Stats: 8 lines in 1 file changed: 0 ins; 8 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/28471.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28471/head:pull/28471
PR: https://git.openjdk.org/jdk/pull/28471
More information about the core-libs-dev
mailing list