C++ performance tips and rules of thumb anyone?
When coding, what is a good rule of thumb to keep in mind with respect to performance? There are endless ways to optimize for a specific platform and compiler, but I'm looking for answers that apply equally well (or almost) across compilers and platforms.
A famous quote come to mind:
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." (Knuth, Donald. Structured Programming with go to Statements, ACM Journal Computing Surveys, Vol 6, No. 4, Dec. 1974. p.268.)
But maybe you should not pass large data structures by value anyway... :-)
Edit: And maybe also avoid O(N^2) or more complex algorithms...