Precompute

Precomputing is a close relative of caching. When you cache a result, you pay the price of computing it once in the performance-critical path. When you precompute, you don't even pay the first time. You perform the precomputation outside the performance-critical path (say, initialization-time) and never pay the price of performing a costly computation inside the performance-critical path.

Back to the Web server implementation for an example: A Web server spends a significant portion of its time manipulating character strings. If you can speed up string manipulation, performance will rise significantly. One string manipulation task we often encountered was uppercasing strings and characters. If the browser sends us an "Accept:" request ...

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.