ChainSafe / ChainSafe/gossamer
refactor: Prefer strconv.Itoa over fmt.Sprint
Open
- Dominant language
- Go
- Stars
- 454
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
## 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.
```go
func BenchmarkStrconv(b *testing.B) {
for j := 0; j < b.N; j++ {
_ = strconv.Itoa(80) //BenchmarkStrconv-16 508842183 2.283 ns/op
}
}
```
vs
```go
func BenchmarkFMT(b *testing.B) {
for j := 0; j < b.N; j++ {
_ = fmt.Sprint(80) // BenchmarkFMT-16 23801236 52.26 ns/op
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.