Minimizing local variable declarations

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Rebornxeno
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 85
Joined: Thu Jun 23, 2011 11:12 am

Re: Minimizing local variable declarations

Post by Rebornxeno »

It was actually just the simple things like grouping related variables together because they likely get called together, and unwrapping a bit. I have a variable that I use in a function that iterates thousands of times before completing, and every iteration I had it re-calculate that variable. On the pdf there was a slide showing using a temp variable to keep some value to be re-used many times in cache, I did that, and voila my program halfed its execution time. If only I was using c++, I see a few more spots where putting things in a temp cache location would be tremendously helpful but java doesn't use pointers and such :(
Post Reply