> MacArthur, Ian (SELEX) (UK) wrote:
> >     awake_ring_head_ = (awake_ring_head_ + 1) & 
> (AWAKE_RING_SIZE - 1);
> 
>       Maybe I'm missing something, but surely a mod (%) would 
> be better:
> 
> awake_ring_head_ = (++awake_ring_head_) % AWAKE_RING_SIZE;
> 
>       No power of 2 restriction (which is a bomb just waiting 
> to go off).
> 
>       Integer divides are low overhead, and gets rid of the -1.
>       The only restriction is that AWAKE_RING_SIZE never be zero ;)


Oh, I wasn't seriously suggesting (well, not all that seriously, anyway)
that we actually change the code - it was just that Mike made reference
to use of ring-buffers and real-time programming. So I pitched in with
my particular favourite hard-to-maintain-optimisation for that
particular case.

That said - I've looked at the code generated for integer mod operations
in the past, and a lot of compilers make a real mess of it, much more
complex than you'd expect (although that may have got better recently.)
And (off at tangent) the fmod code in newlib (and glibc for that matter)
is truly horrible to read...!

-- 
Ian

********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to