Re: [AD] fixtoi optimization

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, Sep 21, 2000 at 05:25:08PM +0200, Jean-Christophe WILK wrote:
> This may not be a revolution for Allegro, but
> replacing
> 
> (x >> 16) + ((x & 0x8000) >> 15)
> 
> by
> 
> ((x + 0x8000) >> 16 )
> 
> in the fixtoi function improves its speed by 20-40%.
> 
> The two implementations seem to give always the same
> result (hopefully!)

The one case when it wouldn't be the same is where x is
0xffff8000.  Then x+0x8000 is 0, giving the result 0, where it
would have been 0x10000.  I'm too tired to realise whether this
matters much though -- maybe it would be vaguely inconsistent to
wrap to 0 in this case?  Or is it to be assumed that the return
from fixtoi is a 16 bit integer?  At worst, it's a pathological
case I think.

George

-- 
Random project update:
09/05/2000: Libnet 0.10.8 uploaded -- a few bugfixes
        http://www.canvaslink.com/libnet/  (try changes-0.10.8.txt)



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/