On 02/12/17 23:44, David Guillen Fandos wrote: > In case I use a bunch of ifs (or a cascaded ? : sequence) it detects > that all the resulting values are the same and therefore there's no need > to add jumps, or even in the case where I use the last "else" to assign > some null value it optimizes on that on subsequent code. It's > interesting to see how switch/case is a special thing and it's never > optimized as if it were a bunch of if/else statements. It's important to measure stuff like this, not just look at the code. Today's processors do an amazing job of branch prediction, and I've found that "improving" naive-looking code doesn't always help. Processors expect to see naive-looking code. -- Andrew Haley Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671