RFR: 8341028: Do not use lambdas or method refs for verifyConstantPool [v3]
David M. Lloyd
duke at openjdk.org
Tue Oct 29 14:28:18 UTC 2024
On Mon, 21 Oct 2024 14:13:35 GMT, David M. Lloyd <duke at openjdk.org> wrote:
>> Currently, `ParserVerifier#verifyConstantPool` uses a `switch` to produce a `Runnable`, which is consumed by a `Consumer<Runnable>` (instantiated within a loop) which runs the task inside if a `try`/`catch`. We can eliminate a number of lambdas and method references, plus some allocation pressure, in this code by simplifying it so that the `switch` is itself run directly within the `try`/`catch`.
>
> David M. Lloyd has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:
>
> - Make sure that we record every error instead of stopping at the first error in a particular CPE
> - 8341028: Do not use lambdas or method refs for verifyConstantPool
>
> Currently, `ParserVerifier#verifyConstantPool` uses a `switch` to produce a `Runnable`, which is consumed by a `Consumer<Runnable>` (instantiated within a loop) which runs the task inside if a `try`/`catch`. We can eliminate a number of lambdas and method references, plus some allocation pressure, in this code by simplifying it so that the `switch` is itself run directly within the `try`/`catch`.
Right, it would be for cases where the user wants to verify every loaded and/or generated class (I've done both so far). That said, if you determine that retaining the style of the original code is more important than removing these allocations, that is OK too (it can always be revisited if these allocations show up on a profile). It was intended as an easy improvement. It's up to you.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21209#issuecomment-2444424735
More information about the core-libs-dev
mailing list