Kas Thomas has an effective piece of advice for writing fast code. If you want to write fast code, make it do less. It seems obvious when stated, but I rarely see it getting applied. Probably because optimization is considered only when required and secondly the modern frameworks are in favour of writing generic and all-inclusive code. It is difficult to refactor such code to do less because usually such code changes need changes in data design or the configuration.
I think this is a brilliant piece of advice, worthy enough to be taught in schools. Not only can it optimize the code, but it can also help reduce accidental complexity.