Chapter 7. Loops, Switches, and Recursion

I have made this letter longer than usual because I lack the time to make it shorter.

Blaise Pascal

This chapter describes performance-tuning a variety of common code structures: loops, switches, and recursion. Some of the tuning hints here are straightforward (for example, remove code from a loop if it is executed only once), but many are more esoteric, particularly given the subtleties of optimizations performed by HotSpot VMs and JIT compilers. Read on for details.