Saturday, December 30, 2006

Padding

static struct
{
unsigned char **segment;
unsigned int *reg1;
unsigned int *reg2;
int offset;
int offset16;
int pad[3]; /* Make structure power of 2 bytes wide for speed */
} ModRMRM[256];

wat is d significant of pad[3]????
how it become fast if structure is of power 2???



ou are taking array of structures...
so for that say u have to access jth element of array ..u do it by array[j] ...how does ur compiler do it is array+j*size of (that is *array) right!!
so if sizefo struct if power of 2 then the multiplication can be speed up by just doing shifting of bits ..accessing array elements by subscript is quite frequent...thats why this practice gives a lot of performance speedup

No comments:

Post a Comment