[Tinyos-devel] One should make limited use of the "%" operator
David Gay
dgay42 at gmail.com
Thu Jun 25 15:18:47 PDT 2009
On Thu, Jun 25, 2009 at 2:54 PM, Michael Newman<mnewman at dragonnorth.com> wrote:
> // Use a small while loop to avoid an expensive
> // library call for the % operator.
> #if 0
> idx %= QUEUE_SIZE;
> #else
> while (idx > QUEUE_SIZE)
> idx -= QUEUE_SIZE;
> #endif
Missing from this whole discussion of if-vs-while: most of the places
I saw % used would be happy with a single 'if' as the value is
internally generated (e.g. walking through a queue).
David, who remembers getting rid of the odd % here and there ;-)
More information about the Tinyos-devel
mailing list