RFR: JDK-8170945: Collectors$Partition should override more Map methods
Viktor Klang
duke at openjdk.org
Wed Apr 5 13:22:15 UTC 2023
On Wed, 5 Apr 2023 12:52:11 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
>> Adds overrides for common Map operations to avoid having to allocate the entrySet for Collectors$Partition maps.
>
> src/java.base/share/classes/java/util/stream/Collectors.java line 1988:
>
>> 1986: public T get(Object key) {
>> 1987: if (key instanceof Boolean b) {
>> 1988: return b.booleanValue() ? forTrue : forFalse;
>
> Can we drop `.booleanValue()` ?
> Suggestion:
>
> return b ? forTrue : forFalse;
@turbanoff Definitely possible, I added it because it visually distinguishes that it is a boxed value, but perhaps relying on autoboxing in this case is just fine.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13347#discussion_r1158509411
More information about the core-libs-dev
mailing list