Whenever anyone asks about optimisation, I'm reminded of the
quote from Michael A. Jackson The First Rule of Program
Optimisation: Don't do it. The Second Rule of Program
Optimisation (for experts only!): Don't do it yet. Quote from
wikipedia corrected for British English. *8') Implicit in the
second rule is to profile your code and only spend time
optimising things which will make a difference. When programming
in assembly, your father's assertion was correct. But that is
much closer to the metal than most people program these days.
Today even trying to optimise yourself (without profiling) can
result in making your code run slower than if you'd done
something the more common way, since the common way is more
likely to be optimised by modern JIT compilers. Even in C you
have to be pretty good at optimisation to know more about how to
optimise a section of code than the compiler does. If you aren't
familiar with much of what Ulrich Drepper talks about in his
excellent paper What Every Programmer Should Know A