Performance dropped significantly when switching from Nested Patterns to Flattened Patterns (was "Sharing my experience with Switch Expressions")

Brian Goetz brian.goetz at oracle.com
Thu Jun 12 20:10:43 UTC 2025


Some amount of this is to be expected, since the flattened style is going to redundantly do a lot of work in a kind of obvious way.  But that’s a pretty big difference, so there may be more going on there.

On Jun 12, 2025, at 4:01 PM, David Alayachew <davidalayachew at gmail.com<mailto:davidalayachew at gmail.com>> wrote:

Whoops, looks like the original thread did not get included during the rename. Here is a link to the original thread -- https://mail.openjdk.org/pipermail/amber-dev/2025-May/009299.html

Alternatively, if you just want to jump to the code examples, I copied and pasted them below.

Nested = https://github.com/davidalayachew/HelltakerPathFinder/blob/12c57dab041924192b8613075ff6966b1b159e91/src/main/java/HelltakerPathFinderModule/HelltakerPathFinderPackage/Board.java#L511

Flattened = https://github.com/davidalayachew/HelltakerPathFinder/blob/10b7a9d5fc4f6f563a68824de9a70735c7533226/src/main/java/HelltakerPathFinderModule/HelltakerPathFinderPackage/Board.java#L512

If you need me to provide a simplified example, I am happy to. Just let me know.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20250612/71234856/attachment.htm>


More information about the amber-dev mailing list