RFR: StateObjectHandler.validateState(): fix typo and optimize [v2]

Sergey Ponomarev github.com+415502+stokito at openjdk.java.net
Sat Oct 24 16:21:47 UTC 2020


On Thu, 22 Oct 2020 13:52:17 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> Sergey Ponomarev has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR.
>
> It might be a good cleanup. However, the style is usually to return `Collection<String>`, and then do e.g.:
> 
>       for (String s : addStateInitializersParamsLabels(so)) writer.println(ident(1) + s);
> 
> ...and remove the indents from the helper methods. That way we can make sure indenting in the generated code is fine. (You might want to check it with your own eyes anyway).

I just canceled the last commit because it doesn't have a big value but I'm afraid to change logic uncovered by tests

> jmh-core/src/main/java/org/openjdk/jmh/generators/core/StateObjectHandler.java line 780:
> 
>> 778:                 }
>> 779:             }
>> 780:             addStateInitializersHelpers(result, so);
> 
> Shouldn't the block above also be replaced with `addStateInitializersParamsLabels`?

Actually there is a lot of duplicated lines across the `generators.core` package but in the same time there is almost no tests. I decided not to touch this code at all. So I rolled back the commit.
It will be very easy to find such duplicates with IntelliJ so nothing really valuable there.

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

PR: https://git.openjdk.java.net/jmh/pull/7


More information about the jmh-dev mailing list