JDK-8302818 : Optimize wrapper sets and immutable sets of Enums
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 11,19
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2023-02-19
  • Updated: 2023-03-15
Related Reports
Relates :  
Description
Currently, the two subclasses of java.util.EnumSet optimize bulk operations when the argument is also a EnumSet, but there is no such optimization for wrapper sets (returned by Collections.unmodifiableSet, Collections.synchronizedSet, etc.) and immutable sets (returned by Set.of methods) of Enums.

These sets can be optimized without changing public APIs.

Notes:
1. The immutable sets will have their iteration order changed, but that's allowed by the API specification.
2. There may be performance impact as there are extra checks to create enum-specific collections.
Comments
May be in Stuart Marks' interest given he's the engineer working on Collections.
15-03-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/12498 Date: 2023-02-09 16:20:31 +0000
20-02-2023