Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8368825

Use switch expression for DateTimeFormatterBuilder pattern character lookup

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      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.

            Unassigned Unassigned
            swen Shaojin Wen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: