What simple techniques do you use to improve performance?
- by Cristian
I'm talking about the way we write simple routines in order to improve performance without making your code harder to read... for instance, this is the typical for we learned:
for(int i = 0; i < collection.length(); i++ ){
// stuff here
}
But, I usually do this when a foreach is not applicable:
for(int i = 0, j = collection.length(); i < j; i++ ){
// stuff here
}
I think this is a better approach since it will call the length method once only... my girlfriend says it's cryptic though. Is there any other simple trick you use on your own developments?