scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.79k stars 1.04k forks source link

Enum ordinals -> tableswitch #5537

Open tpolecat opened 5 years ago

tpolecat commented 5 years ago

Just following up on a conversation @odersky and I had at SBTB … I was wondering if we could use enum ordinals to emit tableswitches for eligible match expressions. I have had cases where I had to reorder cases as a performance optimization and something like this would have been really helpful.

smarter commented 5 years ago

We don't necessarily need to do the same, but for reference here's how Java does it: http://www.benf.org/other/cfr/switch-on-enum.html, it's complicated because it's designed to survive reordering and addition of fields to the enum.

He-Pin commented 5 years ago

This is a must done,take a look at :

https://github.com/akka/akka/pull/25982/files#diff-ac929e6fd84743df4b6e214b5499d644R423

for why...

smarter commented 5 years ago

@hepin1989 without benchmark results you won't convince us that it's a "must done"

He-Pin commented 5 years ago

Same patterns in scala future,zio, etc

bishabosha commented 3 years ago

and we can't rely on mima because definitions are order sensitive