Avoid string-to-byte conversion
Do not create byte slices from a fixed string repeatedly. Instead, perform the conversion once and capture the result.
| Bad | Good |
|---|---|
| ```go for i := 0; i < b.N; i++ { w.Write([]byte("Hello world")) } ``` | ```go data := []byte("Hello world") for i := 0; i < b.N; i++ { w.Write(data) } ``` |
| ```plain BenchmarkBad-4 50000000 22.2 ns/op ``` | ```plain BenchmarkGood-4 500000000 3.25 ns/op ``` |