Correctness is more important than efficiency!  ANd you got the correctness nailed.  In the real world you'll have many competing priorities for your time and you'll have to choose whether to refactor or not.  THere's plenty of production code (i.e. running in the world) that's inefficient.  As long as users don't notice it's probably OK!