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

ZoneIdPrinterParser can be optimized

    XMLWordPrintable

Details

    • 8
    • b147

    Description

      Every time you parse a ZonedDateTime that contains a zone id the method ZoneRulesProvider.getAvailableZoneIds() is called in the ZoneIdPrinterParser.

      This method can be very costly. Since there is already a cache to avoid to recreate the SubstringTree it should be possible
      to call the ZoneRulesProvider.getAvailableZoneIds() method only when this cache is updated.

      For example something like

      Set regionIds = cachedRegionIds;
      final int regionIdsSize = ZoneRulesProvider.getAvailableZoneIdsSize(); // Return only the size of ZONES in ZoneRulesProvider
      Entry cached = cachedSubstringTree;
      if (cached == null || cached.getKey() != regionIdsSize) {
      cachedRegionIds = ZoneRulesProvider.getAvailableZoneIds();
      ...

      Instead of

      Set regionIds = ZoneRulesProvider.getAvailableZoneIds();
      final int regionIdsSize = regionIds.size();
      Entry cached = cachedSubstringTree;
      if (cached == null || cached.getKey() != regionIdsSize) {
      ...



      Originally proposed as https://github.com/ThreeTen/threeten/issues/350

      Attachments

        Activity

          People

            bgopularam Bhanu Prakash Gopularam (Inactive)
            rriggs Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: