I see this code here:
Am I missing something or is it an artifact that remained there after debugging?
I see this code here:
Am I missing something or is it an artifact that remained there after debugging?
curr
is being used two lines down, so no, that’s not dead code.
it is some funky math but seems intentional.
remember, the %
operator in C and C++ has weird semantics. (-1) % 3 == -1
We have i >=3
always
I am not saying it’s dead. I am saying that we could simply write i % 3
instead.
oh right, I’m not quite awake yet. so… it’s index shifting. and the shift shows up in that place, as it should, but it’s all magic constants, which is bad.
such code deserves a few more comments.
anyway, any reasonable compiler will optimize that, so nothing to worry about.