If I put a funky optimisation into "serious" code, I tend to leave the unoptimised version in place in a comment. That way, if I need to make changes, I can either:
- read the unoptimised version to help me figure out what the optimised version does;
- or I can revert to the unoptimised version, easily change the functionality, and then optimise it again if necessary.
Yes, this is different from jus saying "use CVS" :-)