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

eliminate extra array copying in Map.copyOf

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 11
    • Fix Version/s: None
    • Component/s: core-libs

      Description

      A DESCRIPTION OF THE PROBLEM :
      Map.copyOf first creates a temporary array of entries before calling Map.ofEntries.
      Then Map.ofEntries creates another temporary array of objects before calling ImmutableCollections.MapN.
      Finally ImmutableCollections.MapN constructor creates the final object array (table field).

      By simply having another constructor for ImmutableCollections.MapN taking a Set<Map.Entry> as parameter, the two temporary arrays creation/copy could be avoided. Map.copyOf could directly call ImmutableCollections.MapN with map.entrySet. It is significant when using Map.copyOf on large maps.


        Attachments

          Activity

            People

            Assignee:
            smarks Stuart Marks
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: