Author: Zach Wegner
Date: 20:30:04 07/20/03
Go up one level in this thread
>switch (n-i) // sample for 0 >= n-i >= 7
>{
>case 7: f(i--);
>case 6: f(i--);
>case 5: f(i--);
>case 4: f(i--);
>case 3: f(i--);
>case 2: f(i--);
>case 1: f(i);
>case 0: break;
>default: assume (0); // msc specific
>}
>
>Gerd
An uglier, yet less branchy way would be to use a Duff's device:
int j=(n+7)/8;
switch(n%8)
{
case 0: do{ f(i++);
case 7: f(i++);
case 6: f(i++);
case 5: f(i++);
case 4: f(i++);
case 3: f(i++);
case 2: f(i++);
case 1: f(i++);
}while(--j>0);
}
But you did say more readable...
Zach
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.