So use ++i instead of i++.
Why?
Because I've seen a *lot* of code like this:
int nValue = pData[ i++ % 32 ];
When they were clearly trying to do this:
int nValue = pData[ ++i % 32 ];
And actually, it should be even clearer:
++i;
int nIndex = i % 32;
int nValue = pData[ nIndex ];
Remember to code for readability!
(Bug fixed)
2 comments:
Your code has a bug. I think you were trying to write:
++i;
int nIndex = i % 32;
int nValue = pData[nIndex];
Thanks Edmundo! Bug fixed.
Post a Comment