title: Is it faster to compare and set or just set?
body: <p>Which is faster:</p>
  
  <pre><code>if(this.foo != 1234)
     this.foo = 1234;
  </code></pre>
  
  <p>or </p>
  
  <pre><code>this.foo = 1234;
  </code></pre>
  
  <p>is the penalty of write high enough that one should check value before writing or is it faster to just write?</p>
  
  <p>wouldn't having a branch cause possible mispredictions and screwup cpu pipleine? but what is the field is volatile, with writes having higher cost than reads?</p>
  
  <p>yes, it is easy to say that in isolation these operations themselves are 'free' or benchmark it but that is not an answer.</p>