Three Optimization Tips for C++ - by Andrei Alexandrescu
This is an approximate transcript of my talk at Facebook NYC on December 4, 2012, which discusses optimization tips for C++ programs. The video of the talk is here and the accompanying slides are here . Scope Commonly given advice about approaching optimization in general, and optimization of C++ code in particular, includes: Quoting Knuth more or less out of context The classic one-two punch: (a) Don't do it; (b) Don't do it yet Focus on algorithms, not on micro-optimization Most programs are I/O bound Avoid constructing objects unnecessarily Use C++11's rvalue references to implement move constructors That's great advice, save for two issues. First, it has becomed hackneyed by overuse and is often wielded to dogmatically smother new discussions before they even happen. Second, some of it is vague. For example, "choose the right algorithm" is vacuous without a good understanding of what algorithms are best supported by the computing fabri...