[mythtv] Ticket #7759

Davin McCall davmac at davmac.org
Sun Dec 20 21:57:31 UTC 2009


On 21/12/09 02:44, Daniel Kristjansson wrote:
>       repeat_delay = frame_interval / 2 * buffer->repeat_pict;
>    
> I'm revoking your programmers license :) You should never ever use a
> division when a multiply will do. Maybe>>1 is what you meant to
> say? It avoids the conversion from int to double that 0.5 forces.
>
>    

To any even remotely capable compiler, ">>1" and "/2" are pretty much 
the same operation, but the intent of "/2" is more clear. (Yes, avoiding 
the conversion to double was one of the aims - that's an optimization 
the compiler generally won't, and probably isn't allowed to, perform).

I'm still not sure why the division by 2 (no matter how it's done) is 
necessary at all in that particular line of code, however... or at 
least, I'm not certain that it's always correct.

Davin



More information about the mythtv-dev mailing list