title: Is it better to make a local scope variable a class variable if it is being used in an update/listener to avoid it being created every time?
body: <p>Consider the following snippet, where you can get a float (or the corresponding type) from the <code>MyType</code> instance argument:</p>
  <pre><code>void myMethod(MyType floatArgument) {
      float myFloat = (float)MyType.Value;
      if (myFloat &lt; 100) {
          //not meaningfull code
      }
  }
  </code></pre>
  <p>If the method is being continiusly called in a listener, or an Update of a physics or graphics engine, is it strictly better regarding efficiency to make it a class variable like this?? :</p>
  <pre><code>private float myFloat
  void myMethod(MyType floatArgument) {
      myFloat = (float)MyType.Value;
      if (myFloat &lt; 100) {
              //not meaningfull code
      }
  }
  </code></pre>
  <p>The variable is used only in local scope, so AFAIK it would be created in the stack every time. So it would be faster to make a class variable from it, so that even the memory for that variable would be on the heap and the memory consumption would be higher, the code would run faster.</p>
  <p>I know that for a float might not be a big deal, but take it as it if would be lots of variables or an instance of a large data class.</p>
  <p>Is this reasoning correct?</p>