NJ> //Screen[x+y*320] = color;
NJ> Screen[x+(y<<6)+(y<<8)] = color; /* same as above but here the
NJ> multiplication is replaced with
NJ> shifts to make it faster */
DM> Are you SURE that two shift operations followed by an addition is
DM> really faster than the hardware-optimized integer multiplication?
DM> Perhaps on an 8086... but on an 80486? Probably not...
a shift operation on a pentium takes 1 clockcycle where an integer
multiplication takes 9 for 32bit registers and 11 for 16bit
I roughly calculated the number of clockcycles for both calculations:
x+(y 4 clockcycles
x+y*320 => 11 (32bit), 13 (16bit)
so using shifts is still the fastest way.
I do not know if there are compilers who recognize this situation
and optimize it in the fastest(or smallest) way, but I doubt it,
so to be save I just use the shift.
Niels...
--- GEcho 1.11+
---------------
* Origin: Free sex on Softwareboard 0224-218587 {+} Reg.Only (2:280/112)
|