Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8158365 List.spliterator should optimize for RandomAccess lists
  3. JDK-8160814

Release Note: List.spliterator should optimize for RandomAccess lists

    XMLWordPrintable

Details

    Description

      Previously the default implementation of `List.spliterator` derived a `Spliterator` from the `List`'s iterator, which is poorly splitting and that affects the performance of a parallel stream returned by `List.parallelStream`.
      The default implementation of `List.spliterator` now returns an optimal splitting `Spliterator` implementation for `List` implementations that implement `java.util.RandomAccess`. As a result parallel stream performance may be improved for third-party `List` implementations, such as those provided by Eclipse collections, that do not override `List.spliterator` for compatibility across multiple major versions of the Java platform.
      This enhancement is a trade-off. It requires that the `List.get` method, of such lists implementing `RandomAccess`, have no side-effects, ensuring safe concurrent execution of the method when parallel stream pipeline is executed.

      Attachments

        Activity

          People

            psandoz Paul Sandoz
            psandoz Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: