java.time.zone.ZoneRules.getOffset(java.time.Instant) can be optimized

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 9
    • Affects Version/s: None
    • Component/s: core-libs
    • 8
    • b64

        There is a loop over ZoneOffsetTransition[] array that searches for 1st transition that has its toEpochSecond value less than the Instant's epochSecond. This calls ZoneOffsetTransition.toEpochSecond repeatedly, converting ZoneOffsetTransition.transition which is a LocalDateTime to epochSecond. This repeated conversion is unnecessary, as ZoneOffsetTransition[] array is part of ZoneRules which is cached. The simplest form of optimization is for the ZoneOffsetTransition implementation to keep both LocalDateTime variant and epochSecond variant of transition time as the object's state.

              Assignee:
              Peter Levart
              Reporter:
              Peter Levart
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: