Re: [algogeeks] Re: switch vs if --> which is faster

2010-11-22 Thread LALIT SHARMA
I was asking you for some examples ..as i dont have any knowledge regarding this assembly code and how to study it . there was no intention of mine to challenge you or disregard you . On 11/22/10, Gene wrote: > I'm not sure what you mean by support. > > If you mean examples, gcc uses several of

Re: [algogeeks] Re: switch vs if --> which is faster

2010-11-21 Thread LALIT SHARMA
@dipankar Can u tell us , sumthng more in support of ur ans...?? On Mon, Nov 22, 2010 at 10:40 AM, DIPANKAR DUTTA wrote: > both are same .. because any good optimizing compiler generate same assembly > code of them... > > On Mon, Nov 22, 2010 at 9:38 AM, Gene wrote: >> >> A good compiler w

Re: [algogeeks] Re: switch vs if --> which is faster

2010-11-21 Thread DIPANKAR DUTTA
both are same .. because any good optimizing compiler generate same assembly code of them... On Mon, Nov 22, 2010 at 9:38 AM, Gene wrote: > A good compiler will never generate a switch that is slower than an > if...else chain. They will analyze the switch cases and pick one of > several options

Re: [algogeeks] Re: switch vs if --> which is faster

2010-11-21 Thread MOHIT ....
its depend on compiler how it optimize it . he can make binary search tree for this comparison or perform cascading comparison as in if else case .. so worst case complexity will be as of if- else . but for this case switch(i) { case 4: //some operation case 5:// some operation case 6 : // som