Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8156070 Immutable Collections enhancements
  3. JDK-8156071

List.of: reduce array copying during creation

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • None
    • core-libs
    • None

      The various fixed-arg factory methods mostly call internal varargs constructors, causing array creating and element copying. The resulting array is passed to a constructor that creates another array and copies it (or clones it) again. Consider the List.of(...) methods that call the ListN() constructor. This is quite wasteful.

      A likely solution is for the fixed-arg API methods to call an internal varargs method, which can trust the array because it originated internally.

      See Peter Levart's comments here:

      http://mail.openjdk.java.net/pipermail/core-libs-dev/2016-May/040791.html

            smarks Stuart Marks
            smarks Stuart Marks
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: