title: Why is string.IsNullOrEmpty faster than comparison?
body: <p>MS Analyzer recommends to use <code>string.IsNullOrEmpty</code> instead of comparising it either with null or empty string for performance reasons</p>
  
  <p><em>Warning    470 CA1820 : Microsoft.Performance : Replace the call to 'string.operator ==(string, string)' in ... with a call to 'String.IsNullOrEmpty'.</em></p>
  
  <p>Why is that? Shouldn't the requirement to call another function and pass it reference to some object, which then needs to execute some kind of comparison anyway, be more expensive than executing comparison itself?</p>
  
  <p>Example code</p>
  
  <pre><code>void Foo()
  { // throws a warning
      string x = "hello world";
      if (x == null || x == "")
      {
          Console.WriteLine("Empty");
      }
  }
  
  void Foo()
  { // doesn't throw it
      string x = "hello world";
      if (string.IsNullOrEmpty(x))
      {
          Console.WriteLine("Empty");
      }
  }
  </code></pre>