Writing high performance code despite C#
Consider the following C code snippet:
This code cannot be written in C#. Why? Because you can’t use ‘+’ on bool, and you can’t cast bools. So I wrote this code, instead:
And then I changed it to be this code:
Can you tell why I did that? And what is the original code trying to do?
For that matter (and I’m honestly asking here), how would you write this code in C# to get the best performance?
Hint:

Comments
Comment preview