Minimizing local variable declarations
Moderator: Coders of Rage
-
- Chaos Rift Cool Newbie
- Posts: 85
- Joined: Thu Jun 23, 2011 11:12 am
Re: Minimizing local variable declarations
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