To Your current state
It always worked for You to do it? "If it is not broken, don't fix it" is another golden rule which I should stick to more. It caused me lot of headache when I did not stick to it. It can never cause You a problem, but who knows.
As has been said before "do the simplest thing that could possibly work". I found Pike rules on programming to be very enlightening.
What to consider
I assume You mean mostly speed optimization. Because there is also optimization for readability, size ...
Premature optimization is always bad, because:
- It takes time to optimize. You might have spend this time by making something better; for example, calling Your girlfriend;).
- Optimization usually means making things more concrete.
- It will most likely be unreadable to other programmers. Every programmer should know simple algorithms so if there is something more complex he will waste time puzzing on what it means; he will be thninking low level, parsing more information and quite likely making errors in understanding Your optimized code.
- It has been said by Donnald Knuth, which is the authority for programming and if he claims something is some way it is almost certainly so.
- You have to measure first where is Your system slow and THEN optimize. Not the other way around.
For example Quake engine used string compare O(N) to lookup variables instead of hashing O(1), it used scripted language Quake C which took about 10 percent of it's performance and "famous" PVS is simple hashing O(1) with simple compression (visibility is precomputed, each section of world to each section therefore what objects are visible is obtained trough a hash map lookup and since such information is huge in memory it is compressed). Michael Abrash's Graphics Programming Black Book is full of "measure first"" examples and examples where he was wrong estimating what was problem (chapter 17
But premature optimization is not always bad, because:
- There cases when, by optimizing, You can see better solution. But is is about more about a chance.
So You have to weight pros and cons of doing premature optimizations.
I think that, because we are all people You just have to burn Yourself few times with premature optimizations to stop using them.