> > Right, that's one of the things I like about your implementation
> > (that and using the ring buffer, which takes me back to my old
> > real-time programming days... :)
>
> Hah, I've been updating some PIC microcontroller code recently. When
> you have 2k of ROM and 105 bytes of RAM, you learn to save. And I
> generally love the concept of lazy evaluation. It matches my way of
> working.
Well, if we are doing a ring buffer, and worrying about efficiences,
here's my favorite tweak...
For any case where AWAKE_RING_SIZE is a power of two (e.g. 1024, for
example)
Then, code like:
++awake_ring_head_;
if (awake_ring_head_ == awake_ring_size_)
awake_ring_head_ = 0;
Can be replaced by:
awake_ring_head_ = (awake_ring_head_ + 1) & (AWAKE_RING_SIZE -
1);
Which has the same effect, but no conditional test and therefore no
branch cost.
(And there are similar masking hacks to determine fullnes or otherwise
with only one conditional test too, IIRC...)
And, while I think of it - does AWAKE_RING_SIZE have the wrong scope?
Should it be static here?
--
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