Key Points
Coding optimizations are local in scope and do not necessitate understanding of overall program design. This is a good place to start when you join an ongoing project whose design you don't yet understand.
The fastest code is the one that's never executed. Try the following to bail out of a costly computation:
Are you ever going to use the result? It sounds silly, but it happens. At times we perform computation and never use the results.
Do you need the results now? Defer a computation to the point where it is actually needed. Premature computations may never be used on some execution flows.
Do you know the result already? We have seen costly computations performed even though their results were available two lines above. If you already ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access