Lazy Evaluation

Many performance optimizations gain speed by taking a computation and performing it in a more efficient manner. Some of the big performance wins in the optimization game are achieved not by merely speeding up a computation but by eliminating it altogether.

Issues of lazy evaluation are more likely to present themselves on large-scale code. If you are coding a solution for, say, the Traveling Salesman Problem (TSP), the problem description fits in one paragraph and the implementation is less than 100 lines of code. The TSP problem description and implementation can fully be comprehended by a single developer. That's typical of small scale projects. In such circumstances you are highly unlikely to find costly computations that are ...

Get Efficient C++ Performance Programming Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.