Saturday, August 6, 2005, 5:56:00 PM, you wrote:

AP> Hi all,

AP> I was wondering if the getbyte macro found in misc.h is as
AP> optimal as it can be...

AP> I propose using a shift-left by 3 instead of an integer
AP> multiply by 8.


AP> original macro:
AP> GETBYTE(x, y) (unsigned int)byte((x)>>(8*(y)))

AP> updated macro:
AP> GETBYTE(x, y) (unsigned int)byte((x)>>(y<<3))


AP> Is there anything wrong with this idea?

This is something that optimizing compilers learnt how to do many
years ago.

To convince yourself have a look at the generated assembler code in
the debugger.

If you're concerned about performance then you should be using a
profiler to find hot spots, and not be concerned with issues like
this.

-- 
Best regards,
  Neville Franks, Author of Surfulater and ED for Windows 
  Soft As It Gets Pty Ltd, http://www.surfulater.com - http://www.getsoft.com
  Victoria, Australia
 

Reply via email to