Re: performance of the swtich/case statements

2014-10-30 Thread Erich Dollansky
Hi, On Thu, 30 Oct 2014 12:24:33 +0800 bycn82 byc...@gmail.com wrote: Hi, According to my understanding in Java programming, the compiler will aren't we talking about C here? Erich automatically store the values into a table and jump to the correct one according to the value only when

Re: performance of the swtich/case statements

2014-10-30 Thread Alfred Perlstein
Please run compiler with -O2 -S to get the assembly to see what will actually happen. thanks, -Alfred On 10/29/14 9:24 PM, bycn82 wrote: Hi, According to my understanding in Java programming, the compiler will automatically store the values into a table and jump to the correct one according

Re: performance of the swtich/case statements

2014-10-30 Thread bycn82
actually I just checked that, no performance concern on the switch/case statement already, the compiler will sort the conditions in cases statements ,and since the opcodes are define in an enum, so the compiler will find out that all the conditions are in sequences :) On Fri, Oct 31, 2014 at 1:30

Re: performance of the swtich/case statements

2014-10-29 Thread bycn82
Hi, According to my understanding in Java programming, the compiler will automatically store the values into a table and jump to the correct one according to the value only when the condition values are in running number, for example. swtich(a){ case 1: code block 1 case 2: code block 2 case