gossamer
gossamer copied to clipboard
refactor: Prefer strconv.Itoa over fmt.Sprint
Issue summary
strconv.Itoa is faster than fmt.Sprint and is preferred for converting integers to strings. The example below demonstrates the difference between them.
func BenchmarkStrconv(b *testing.B) {
for j := 0; j < b.N; j++ {
_ = strconv.Itoa(80) //BenchmarkStrconv-16 508842183 2.283 ns/op
}
}
vs
func BenchmarkFMT(b *testing.B) {
for j := 0; j < b.N; j++ {
_ = fmt.Sprint(80) // BenchmarkFMT-16 23801236 52.26 ns/op
}
}
If you think this makes sense, can I take this issue?