Re: [AD] bool in MSVC

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


On Wednesday 24 March 2010 8:00:25 pm Evert Glebbeek wrote:
> On 24 Mar 2010, at 22:49 , Peter Wang wrote:
> >> Looks correct to me (unlike the above code).
> 
> Actually, on second thought, (onoff && (display->flags &
> ALLEGRO_FULLSCREEN_WINDOW != 0)) is probably what was intended there.
> 
> > You can write
> > 
> >    (onoff == !!(display->flags & ALLEGRO_FULLSCREEN_WINDOW))
> 
> You could.
> I think I prefer what I just came up with. :P

I think the latter could optimize better, given C's requirement for short-
circuiting. The former must not dereference 'display' if 'onoff' is false 
(forcing a branch), whereas the latter can possibly optimize out any branching 
because display->flags needs to be evaluated anyway.

Granted, I have no idea if this is time-sensitive code that would benefit from 
such, but I figured I'd toss that out there.




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