title: Why strings.HasPrefix is faster than bytes.HasPrefix?
body: <p>In my code, I have such benchmark:</p>
  
  <pre><code>const STR = "abcd"
  const PREFIX = "ab"
  var STR_B = []byte(STR)
  var PREFIX_B = []byte(PREFIX)
  
  func BenchmarkStrHasPrefix(b *testing.B) {
      for i := 0; i &lt; b.N; i++ {
          strings.HasPrefix(STR, PREFIX)
      }
  }
  
  func BenchmarkBytHasPrefix(b *testing.B) {
      for i := 0; i &lt; b.N; i++ {
          bytes.HasPrefix(STR_B, PREFIX_B)
      }
  }
  </code></pre>
  
  <p>And I am little bit confused about results:</p>
  
  <pre><code>BenchmarkStrHasPrefix-4    300000000    4.67 ns/op
  BenchmarkBytHasPrefix-4    200000000    8.05 ns/op
  </code></pre>
  
  <p>Why there is up to 2x difference?</p>
  
  <p>Thanks.</p>