Code hoisting is an optimization technique that moves code from inside a loop to outside of the loop, if the code is not dependent on being inside the loop (i.e., the code moved is loop-invariant). If your compiler doesn’t have an …
Read moreLoop unrolling as a symptom of premature optimization
I was asked a question recently that went something like this: “If a for loop is faster when it’s unrolled, why does my boss always want me to make my code shorter by using for loops, when my way (loop …
Read moreAre compilers really better than human programmers at optimizing code?
The choice of the most appropriate and efficient algorithm is the most important optimization there is. And it needs to be implemented correctly, of course. A compiler can’t do this for you. It requires a human. And most of the …
Read more