RFR: 8372460: Use EnumMap instead of HashMap for DateTimeFormatter parsing to improve performance [v4]
Shaojin Wen
swen at openjdk.org
Tue Dec 2 01:53:46 UTC 2025
On Mon, 1 Dec 2025 14:12:42 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
> Spreading out and duplicating the state across multiple classes isn't very satisfactory. Since non-ChronoField is very unlikely, I'd suggest a more localized change confined to Parsed. Always create the initial EnumMap and refactor the `fieldValues.put()` calls to a private utility method to catch the ClassCatchException and upgrade the map to a HashMap. That should retain the performance improvements without any extra overhead or non-local code changes for all of the normal cases.
I also plan to upgrade EnumMap to a custom ChronoFieldMap, like this: https://github.com/wenshao/jdk/commit/b1cbc6295aa339a666996e910f46ab351e44726a Keeping the current implementation would be easier.
<img width="2666" height="548" alt="image" src="https://github.com/user-attachments/assets/30ede42c-1df7-4599-8541-5a1d3ce03f73" />
-------------
PR Comment: https://git.openjdk.org/jdk/pull/28471#issuecomment-3599787338
More information about the core-libs-dev
mailing list