RFR: 7903321: Use a set instead of a map to record methods in class 'MethodGroup' [v2]

Guoxiong Li gli at openjdk.org
Wed Sep 21 11:02:58 UTC 2022


On Wed, 21 Sep 2022 10:41:26 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Simplify the method 'addMethod'.
>
> jmh-core/src/main/java/org/openjdk/jmh/generators/core/MethodGroup.java line 75:
> 
>> 73:     public void addMethod(MethodInfo method, int threads) {
>> 74:         MethodInvocation mi = new MethodInvocation(method, threads);
>> 75:         if (methods.contains(mi)) {
> 
> This could be simplified to `if (!methods.add(mi)) {`. This is a pretty idiom for adding the element once while testing for its existence.

Good suggestion. Fixed.

-------------

PR: https://git.openjdk.org/jmh/pull/79


More information about the jmh-dev mailing list