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

(coll) Please improve efficiency of implementation of immutable enum sets

    Details

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

      Description

      It would be very helpful to have an efficient implementation of
      enumeration set constants, to replace existing uses of bit masks.

      Collections.unmodifiableSet called on an EnumSet
      currently creates a set that is two layers of wrapping around a long.
      Operations using this immutable enum set can be quite inefficient.
      For example, given

         public static final Set<Letter> vowels =
      Collections.unmodifiableSet(EnumSet.of(A, E, I, O, U));

      and

         Set<Letter> x = EnumSet.noneOf(Letter.class);

      the implementation of

         x.addAll(vowels);

      reverts to the very inefficient iterator version rather than a
      bit-based implementation.

      This improvement could be done without adding any API elements, by
      specializing the implementation in Collections.unmodifiableSet.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gafter Neal Gafter
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: