decoder: Avoid allocation in readLine
readLine is used in many text decoders, so it pays off if we care not to do allocation for result on every readLine call: name old time/op new time/op delta Speed-4 378ns ± 0% 379ns ± 1% ~ (p=0.397 n=5+5) Decode-4 70.1µs ± 0% 67.3µs ± 0% -3.97% (p=0.008 n=5+5) Encode-4 16.6µs ± 0% 16.6µs ± 0% ~ (p=0.548 n=5+5) name old alloc/op new alloc/op delta Speed-4 280B ± 0% 280B ± 0% ~ (all equal) Decode-4 32.3kB ± 0% 31.0kB ± 0% -3.87% (p=0.008 n=5+5) Encode-4 6.54kB ± 0% 6.54kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta Speed-4 8.00 ± 0% 8.00 ± 0% ~ (all equal) Decode-4 428 ± 0% 326 ± 0% -23.83% (p=0.008 n=5+5) Encode-4 297 ± 0% 297 ± 0% ~ (all equal)
Showing
Please register or sign in to comment