RFR: 7903321: Use a set instead of a map to record methods in class 'MethodGroup'
Aleksey Shipilev
shade at openjdk.org
Wed Sep 21 10:44:33 UTC 2022
On Wed, 21 Sep 2022 10:33:03 GMT, Guoxiong Li <gli at openjdk.org> wrote:
> Hi all,
>
> This patch changes the type of the field `MethodGroup#methods` from a map to a set so that it is more suitable for its meaning.
>
> Thanks for the taking the time to review.
>
> Best Regards,
> -- Guoxiong
This looks fine, but we can make it simpler. Let's see that all GHA tests are also green.
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.
-------------
Changes requested by shade (Committer).
PR: https://git.openjdk.org/jmh/pull/79
More information about the jmh-dev
mailing list