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

eliminate extra array copying in Map.copyOf

XMLWordPrintable

      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.


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

              Created:
              Updated: