Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decode: use unsafe []byte->string conversion for discarded value
For Decode's MLI4I, we invoke strconv.Atoi after string(*b) which incurs a []byte->string allocation. The converted []byte->string is discarded so anyways it is okay to use unsafe, as the string is never used again. Results: * time/op (ns/op) Encoding/Decoding_2I-8 7.5ns ± 1% 6.7ns ± 0% -10.36% (p=0.000 n=10+9) Encoding/Decoding_4E-8 8.8ns ± 0% 7.9ns ± 0% -10.35% (p=0.000 n=10+10) Encoding/Decoding_A4E-8 38ns ± 1% 17ns ± 0% -54.84% (p=0.000 n=10+10) * allocs/op (B/op) Encoding/Decoding_A4E-8 4.0B ± 0% 0 -100.00% (p=0.000 n=10+10) * allocs/op (N/op) Encoding/Decoding_A4E-8 1.0 ± 0% 0 -100.00% (p=0.000 n=10+10)
- Loading branch information