Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v2]

2023-02-20 Thread Tingjun Yuan
On Mon, 20 Feb 2023 13:58:01 GMT, liach wrote: > no, Set.copyOf explicitly allows duplications, unlike Set.of. You need to > read the specs so you know what you are doing. Sorry, my bad. I've fixed that. - PR: https://git.openjdk.org/jdk/pull/12498

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v2]

2023-02-20 Thread liach
On Mon, 20 Feb 2023 13:24:27 GMT, Tingjun Yuan wrote: >> src/java.base/share/classes/java/util/Set.java line 742: >> >>> 740: E e1 = it.next(); >>> 741: if (!it.hasNext()) { >>> 742: return Set.of(e0, e1); >> >> Bad change, doesn't handle e0.equals(e1), and this is g

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v2]

2023-02-20 Thread Tingjun Yuan
On Mon, 20 Feb 2023 13:29:52 GMT, Tingjun Yuan wrote: > I wonder why the original code didn't use `addAll`, so I didn't change it. 😂 It seems to be okay to use `addAll` in all cases. Do we need extra test cases for this? - PR: https://git.openjdk.org/jdk/pull/12498

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v2]

2023-02-20 Thread Tingjun Yuan
On Mon, 20 Feb 2023 13:16:09 GMT, liach wrote: >> Tingjun Yuan has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Optimize `EnumSet.copyOf` and `Set.copyOf` > > src/java.base/share/classes/java/util/EnumSet.java line 186: > >> 184:

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v2]

2023-02-20 Thread Tingjun Yuan
On Mon, 20 Feb 2023 13:15:20 GMT, liach wrote: > Bad change, doesn't handle e0.equals(e1), and this is getting beyond the > original issue `Set.of(E, E)` handles duplication. If `coll` is `{Jumbo,Regular}EnumSetCompatible`, then we don't have to create the `HashSet`. - PR: https:

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v2]

2023-02-20 Thread liach
On Mon, 20 Feb 2023 13:15:03 GMT, Tingjun Yuan 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.syn

Re: RFR: 8302818: Optimize wrapper sets and immutable sets of Enums [v2]

2023-02-20 Thread Tingjun Yuan
> 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