Let's say you have a method that is called extremely often. In general (I'm sure there are exceptions) is it faster to declare a local, let's say, integer, and use that, or is it faster to add an extra integer field to the type and reuse that with each call to the method?
At first I thought it'd be faster to use the pre-instantiated field value since each call to the function wouldn't allocate a new local variable. But a local variable is going to be allocated on the stack and so therefore should prove faster to access. So in general, is one method faster than another?
At first I thought it'd be faster to use the pre-instantiated field value since each call to the function wouldn't allocate a new local variable. But a local variable is going to be allocated on the stack and so therefore should prove faster to access. So in general, is one method faster than another?