Re:What is your favourite C programming trick?
by matthavener on Friday October 14, 2011 @10:29AM
(#3111276)
The ring buffer is a nice trick, but it only works on array sizes that are a multiple of 2. The generalized version would be "array[i++ % ARRAY_SIZE] = data". If ARRAY_SIZE happens to be a multiple of two, I'm sure most compilers would optimize to a bitmask anyways..
[ Parent
| on HN ]