title: Speed difference between global and object variable
body: <p>Is it faster to access a global or object variable?</p>
  
  <p>In C++, I'm referring to the difference between</p>
  
  <pre><code>::foo
  </code></pre>
  
  <p>and</p>
  
  <pre><code>this-&gt;foo
  </code></pre>
  
  <p>In x86 assembler, this basically translates to</p>
  
  <pre><code>mov eax, offset foo
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>mov eax, dword ptr[edx+foo]
  </code></pre>
  
  <p>All data in both cases is expected to be in cache.</p>
  
  <p>(I know the difference if any will be tiny, and one should usually go with whichever makes the code simpler; but in this case there is literally no other difference, and the code in question will be called maybe half a billion times under a time limit, so I might as well go with whichever is even slightly faster.)</p>