Quote Originally Posted by Sachiru View Post
I'd like to ask the forumers here for advice on optimizing my code so that it is:

a) smaller
b) simpler
c) well-documented (prefer this)
d) faster (prefer this over size)
a. Smaller how? fewer lines of code? fewer statements?

d. The first question to ask about spending time on performance optimization is "Is it necessary?". If you don't have clear evidence of a performance problem, why waste your time and risk introducing bugs? If you do have clear evidence of a performance problem, you must establish what is causing it, and tackle that specific area. For this you should use a performance profiler that will time how long various methods take and indicate where the bottlenecks are. In general, going in 'blind' to try and optimize code is unlikely to have any significant benefit (unless you are particularly well experienced in that area).

Premature optimization is the root of all evil in programming...
C.A.R. Hoare