Use a set instead of a map to record methods in class `MethodGroup`

Aleksey Shipilev shade at redhat.com
Wed Sep 21 08:26:51 UTC 2022


On 9/21/22 03:48, Guoxiong Li wrote:
> Hi all,
> 
> I notice there is a field `Map<MethodInvocation, MethodInvocation> methods`
> in the class `org.openjdk.jmh.generators.core.MethodGroup`.
> It is used to record all the methods of one group and
> the key and value of one entry of the map is always the same.
>  From the program's meaning, I think it is good to use a set instead of a map.
> And this implementation confused the newbie, like me,
> so that I needed more time to read the related code to confirm its meaning.
> 
> So I propose to change it from a map to a set.
> I know the `TreeSet` is implemented by using a `TreeMap` internally,
> but it is clearer about the program's meaning by using a set.

It looks like you are correct, it could be TreeSet instead. Please submit the PR?

-- 
Thanks,
-Aleksey



More information about the jmh-dev mailing list