Is using a jump statement more faster than using if statement

Is using a jump statement more faster than using if statement

Post by bGlhbnF0bG » Thu, 07 Feb 2008 11:54:00


Is using a jump statement more faster than using if statement

with a jump statement
example

for(int i=0; i < 10; i++)
{

if(a[i] == null)
{
continue;
}
a[i] =10;

}

or

no jump statement
example

for(int i=0; i < 10; i++)
{
if(a[i] !=null)
{
a[i] =10;
}
}
 
 
 

Is using a jump statement more faster than using if statement

Post by Nicholas P » Thu, 07 Feb 2008 12:53:35


It's probably the same, as the IL will produce a jump statement of some
kind to move to the next iteration of the loop, which is the same thing the
continue is going to do.

It really shouldn't matter, unless you are doing this so many times and
you have identified this loop as being a bottleneck (while at the same time
identifying that the operations that are actually getting performed in the
loop are ^not^ bottlenecks).


--
- Nicholas Paldino [.NET/C# MVP]
- XXXX@XXXXX.COM