There was a fun article on the usual sites about the rules of code optimization: http://fetter.org/optimization.html
I think their list is pretty good for the most part, but I have my own first two rules for code optimization club:
- The first rule of optimization club is, you do not optimize before profiling.
- The second rule of optimization club is, YOU DO NOT OPTIMIZE BEFORE PROFILING!
I particularly like their Rule #3: "If your app is running faster than the underlying transport protocol, the optimization is over."