On Tue, 21 Feb 2023 03:39:46 GMT, Tingjun Yuan <d...@openjdk.org> wrote:
>> 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 `Enum`s. >> >> This PR introduces optimization classes for these situations. No public >> APIs are changed. > > Tingjun Yuan has updated the pull request incrementally with one additional > commit since the last revision: > > Set.copyOf: need defensive copy Thanks again for reviewing. Correct me if I'm wrong. @cl4es I need to add these new wrapper classes `{Unmodifiable,Synchronized}{Regular,Jumbo}EnumSet` to implement interfaces `{Regular,Jumbo}EnumSetCompatible`, just like `*RandomAccessList` which appear to implement `RandomAccess`. I don't think removing these wrapper classes and introducing accessors is a good idea, because I will have to check for the wrapper classes in bulk operation methods, which are used more frequently. @pavelrappo `{Unmodifiable,Sychronized}Set` also have subclasses implementing `SortedSet` and `NavigableSet`, I'm not sure whether `instanceof` is safe for these subclasses. ------------- PR Comment: https://git.openjdk.org/jdk/pull/12498#issuecomment-1478658361