Leart about performance here:
Next, on my local programming IRC channel, I shared a little trick I’d seen on Twitter for replacing a div with a shift:
(i+1)%3 == (1<<i)&3
for i in [0, 2]. One person strenuously objected to the idea of using this trick. Paraphrasing, their argument went something like "the meaning of the code is not clear, so tricks like that should be left to the compiler, but it doesn’t work for all values of i, so a compiler would never actually substitute the left for the right.
Just don’t bother."
http://chadaustin.me/2015/04/thinking-about-performance/Truly Expert.