O'Reilly logo

Efficient C++ Performance Programming Techniques by David Mayhew, Dov Bulka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Caching

Caching is often associated with data and instruction caching on modern processors. But, caching opportunities appear in much wider contexts, including application-level coding and design. Caching is about remembering the results of frequent and costly computations, so that you will not have to perform those computations over and over again.

Caching opportunities are easier to detect and implement in the coding arena. Evaluating constant expressions inside a loop is a well known performance inefficiency. For example:

for(... ;!done;... ) {
   done = patternMatch(pat1, pat2, isCaseSensitive());
   }

The patternMatch() function takes two string patterns to match and a third argument indicating whether a case-sensitive match is required. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required