skipping a statemnet from inside a repeating block
Gopan
gopan.gopalakrishnan at gmail.com
Sat Feb 16 09:21:18 PST 2013
On Thursday, 14 February 2013 at 13:29:07 UTC, John Colvin wrote:
>
> Not internally to the function, no.
>
> In truth, there's no need to do this. Branch prediction
> (http://en.wikipedia.org/wiki/Branch_predictor) should reduce
> the cost hugely.
Thank you for the link. I will see this and come back.
> Also, a comparison is only going to be 1 cycle, saving a single
> cycle per second is irrelevant.
For iterating through a ranges of indices in a circular way, I
have seen people coding like
int i=0;
while(true)
{
...
i = (i+1)%10;
}
People argue i = (i+1)%10 is less costly to the combination below.
++i;
if(i==10)
i = 0;
If the comparison instruction takes only one cycle, how is this
argument correct? Please let me know if that argument is
incorrect.
Thanks,
Gopan.
More information about the Digitalmars-d
mailing list