Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We allocate once via "make([]byte, len)", and again when that buffer is converted to a string. Thankfully, since Go 1.10 we have strings.Builder, designed specifically for this use case. In a downstream benchmark in go-car, which needs to reconstruct many CID values, we see small but nice gains: name old time/op new time/op delta ReadBlocks-16 1.09ms ± 4% 1.06ms ± 5% -3.33% (p=0.007 n=11+11) name old speed new speed delta ReadBlocks-16 478MB/s ± 4% 494MB/s ± 5% +3.46% (p=0.007 n=11+11) name old alloc/op new alloc/op delta ReadBlocks-16 1.30MB ± 0% 1.25MB ± 0% -3.86% (p=0.000 n=12+12) name old allocs/op new allocs/op delta ReadBlocks-16 9.50k ± 0% 8.45k ± 0% -11.05% (p=0.000 n=12+12)
- Loading branch information