Understanding that no code is faster than no code
The phrase No code is faster than no code was the motto of the old Ruby web framework named Merb, which focused heavily on performance. Another, less poetic way of phrasing the same principle is, If you can get the same result without executing any code, any approach that requires executing code will be slower. A simplification of the principle would be, The fastest code is usually the code that does the least. In general, if you want the code to be as fast as possible, you need to find a way to get the same results while doing less work.
There are cases where doing less work can require an algorithmic change, such as changing from a linear scan of an array to using a hash table lookup. There are other cases where doing less work can be accomplished by caching results. Sometimes, doing less work can be accomplished by restructuring your code to delay computation until it is needed, or even better, figuring out computation is not...