Re: RFR: 8300237: Minor improvements in MethodHandles [v3]

2023-01-17 Thread Sergey Tsypanov
> - `MethodType.ptypes()` can be used instead of `MethodType.parameterList()` 
> when we don't need a copy
> - comparison of two lists can be done without `Stream.reduce()`

Sergey Tsypanov has updated the pull request incrementally with one additional 
commit since the last revision:

  Polishing

-

Changes:
  - all: https://git.openjdk.org/jdk/pull/12025/files
  - new: https://git.openjdk.org/jdk/pull/12025/files/6d1397c4..cab00aee

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12025&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12025&range=01-02

  Stats: 14 lines in 1 file changed: 0 ins; 6 del; 8 mod
  Patch: https://git.openjdk.org/jdk/pull/12025.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12025/head:pull/12025

PR: https://git.openjdk.org/jdk/pull/12025


Re: RFR: 8300237: Minor improvements in MethodHandles [v3]

2023-01-17 Thread Sergey Tsypanov
On Tue, 17 Jan 2023 15:30:12 GMT, Rémi Forax  wrote:

>> Precious little method handle use in lambda bootstrap since JDK 11. Though I 
>> agree with the sentiment - having fixed a number of bootstrap issues in the 
>> past - `MethodHandles` is a small step up the abstraction ladder and the 
>> code in particular already uses a number of method refs and lambdas.
>
> ok, two small changes,
> -  formatting: usually the method call in a stream are aligned with the '.' 
> at the beginning
> ```
>  stream
>.filter(...)
>   .map(...)
>```
>instead of at the end.
> 
> - the reduce is a max(),
>   `max(Comparator.comparingInt(List::size))`

@forax formatting is fixed. As of max() I think we can improve this even more 
by hoisting max() before calling ptypes()

-

PR: https://git.openjdk.org/jdk/pull/12025


Re: RFR: 8300237: Minor improvements in MethodHandles [v3]

2023-01-17 Thread Rémi Forax
On Tue, 17 Jan 2023 18:07:37 GMT, Sergey Tsypanov  wrote:

>> - `MethodType.ptypes()` can be used instead of `MethodType.parameterList()` 
>> when we don't need a copy
>> - comparison of two lists can be done without `Stream.reduce()`
>
> Sergey Tsypanov has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Polishing

src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 59:

> 57: import java.nio.ByteOrder;
> 58: import java.security.ProtectionDomain;
> 59: import java.util.*;

oops

src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 6747:

> 6745: .max(Comparator.comparing(MethodType::parameterCount))
> 6746: .map(MethodType::ptypes)
> 6747: .map(longest -> List.of(Arrays.copyOfRange(longest, 
> skipSize, longest.length)))

i think you can fuse these to map() calls

-

PR: https://git.openjdk.org/jdk/pull/12025


Re: RFR: 8300237: Minor improvements in MethodHandles [v3]

2023-01-17 Thread Sergey Tsypanov
On Tue, 17 Jan 2023 20:51:06 GMT, Rémi Forax  wrote:

>> Sergey Tsypanov has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Polishing
>
> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 59:
> 
>> 57: import java.nio.ByteOrder;
>> 58: import java.security.ProtectionDomain;
>> 59: import java.util.*;
> 
> oops

Reverted

> src/java.base/share/classes/java/lang/invoke/MethodHandles.java line 6747:
> 
>> 6745: .max(Comparator.comparing(MethodType::parameterCount))
>> 6746: .map(MethodType::ptypes)
>> 6747: .map(longest -> List.of(Arrays.copyOfRange(longest, 
>> skipSize, longest.length)))
> 
> i think you can fuse these two map() calls

Done!

-

PR: https://git.openjdk.org/jdk/pull/12025