array or functions what is better?
Posted: 29 Oct 2007, 15:03
strelka has a big array Distance[64][64] to calculate distance between squares
I have the following definition in movei to calculate the same thing
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define FileDistance(a,b) abs(((a)&7) - ((b)&7))
#define RankDistance(a,b) abs(((a)>>3) - ((b)>>3))
#define Distance(a,b) Max(FileDistance(a,b),RankDistance(a,b))
I added this definition to strelka and found that Distance(i,j) in my code is always equal to Distance[i][j] in strelka for 0<=i,j<=63
My question is which code is better for speed.
Uri
I have the following definition in movei to calculate the same thing
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define FileDistance(a,b) abs(((a)&7) - ((b)&7))
#define RankDistance(a,b) abs(((a)>>3) - ((b)>>3))
#define Distance(a,b) Max(FileDistance(a,b),RankDistance(a,b))
I added this definition to strelka and found that Distance(i,j) in my code is always equal to Distance[i][j] in strelka for 0<=i,j<=63
My question is which code is better for speed.
Uri