Hacker News new | ask | show | jobs
by ShaunK 4278 days ago
Rather than conditionally execute code (to avoid performing an unnecessary expensive operation) always execute the code, then discard the result if it is unneeded. The idea being that the performance gained by avoiding the unnecessary operation is not worth the complexity added.
2 comments

As a minor note, conditional checks can have significant performance impacts if you don't consistently handle the conditional.

As an example performing an operation every other frame can cause your CPU to thrash due to always taking the wrong path. (I of course am oversimplifying and OOO CPUs are quite complex)

Also adds consistency, which I'm sure is important in realtime games