The DateTimeFormatterBuilder:: FIELD_MAP previously used a Map<Character, TemporalField> for mapping pattern characters to TemporalField
instances. This PR refactors that implementation to use a switch expression instead, which eliminates the need to hold a Map in
memory.
The switch expression approach offers these advantages:
- No memory overhead for maintaining a HashMap structure
- More direct character-to-field mapping without hash computation
- Better code readability and maintainability
This change maintains the same functionality while improving the memory efficiency of pattern character lookup in
DateTimeFormatterBuilder by eliminating the static Map that was previously used for character-to-field mapping.
instances. This PR refactors that implementation to use a switch expression instead, which eliminates the need to hold a Map in
memory.
The switch expression approach offers these advantages:
- No memory overhead for maintaining a HashMap structure
- More direct character-to-field mapping without hash computation
- Better code readability and maintainability
This change maintains the same functionality while improving the memory efficiency of pattern character lookup in
DateTimeFormatterBuilder by eliminating the static Map that was previously used for character-to-field mapping.
- links to
-
Review(master) openjdk/jdk/26634