Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shares: use more efficient make([]byte, N) not bytes.Repeat([]byte{0}…
…, N) This change uses Go's memory model guarantees that the zero value memory shall be zeroed and hence to create a slice of 0 bytes aka padding, we can simply use make([]byte, N) which is much more efficient than bytes.Repeat([]byte{0}, N) and the benchmarks show this improvement: ```shell $ benchstat before.txt after.txt name old time/op new time/op delta PaddingVsRepeat-8 674ns ± 1% 538ns ± 0% -20.22% (p=0.000 n=9+9) name old alloc/op new alloc/op delta PaddingVsRepeat-8 1.31kB ± 0% 0.83kB ± 0% -36.59% (p=0.000 n=10+10) name old allocs/op new allocs/op delta PaddingVsRepeat-8 12.0 ± 0% 11.0 ± 0% -8.33% (p=0.000 n=10+10) ```
- Loading branch information