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

Reduce allocation overhead in java.time.Period/Duration parse methods

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b28
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        java.time.Duration#parse uses a regex to parse a Strings like PT3M23.232S. Current method to parse this generates a number of String objects which are then parsed. By using offset based parse methods (8041972) we can avoid most String creation.

        Same thing applies to java.time.Period

        Other possible improvements:
        - not doing string concatenation to pad nanos fraction (parsing first then multiplying is up to 6x faster and allocation free)
        - not manifesting String objects (matcher.group(x)) for single char matches

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  redestad Claes Redestad
                  Reporter:
                  redestad Claes Redestad
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: