by kabdib · 12y ago · 0 comments
The loop version works poorly for large queue sizes, and if I saw this in production code I'd replace it immediately.
I'd be okay with a division and re-multiplication (likely going to be optimized by the compiler, through it's foolish to depend on this).
I don't see any problem with the mask/not/and solution. This has been a programming idiom for decades, and should be no more mysterious than (say) a doubly-linked list.
I asked around the room and the consensus is that a decade of C has brain damaged me.