2011-02-22

Optimizing the for loop for fun and profit

The three-expression, C style for loop is one of the most useful iteration statements in many programming languages including C#, javascript and perl. However it is commonly used in a sloppy manner and can often be optimized for better performance which is why I have set out to try and explain the inner workings of the for loop in this blog post. This is pretty basic stuff but it seems a fair share of developers has overseen the details of how the for loop really, really works when learning it.