What simple techniques do you use to improve performance?

Posted by Cristian on Programmers See other posts from Programmers or by Cristian
Published on 2010-09-25T23:03:13Z Indexed on 2011/01/30 23:32 UTC
Read the original article Hit count: 346

Filed under:
|

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?

© Programmers or respective owner

Related posts about code-quality

Related posts about Performance