• Kirill Smelkov's avatar
    decoder: Preallocate .buf capacity when we know (approximate) size of output to it · 14aaa14f
    Kirill Smelkov authored
    This reduces allocations a bit:
    
        name      old time/op    new time/op    delta
        Speed-4      383ns ± 4%     378ns ± 0%    ~     (p=0.302 n=5+5)
        Decode-4    72.1µs ± 1%    70.1µs ± 0%  -2.76%  (p=0.008 n=5+5)
        Encode-4    16.5µs ± 0%    16.6µs ± 0%    ~     (p=0.095 n=5+5)
    
        name      old alloc/op   new alloc/op   delta
        Speed-4       280B ± 0%      280B ± 0%    ~     (all equal)
        Decode-4    35.7kB ± 0%    32.3kB ± 0%  -9.72%  (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       429 ± 0%       428 ± 0%  -0.23%  (p=0.008 n=5+5)
        Encode-4       297 ± 0%       297 ± 0%    ~     (all equal)
    14aaa14f
ogorek.go 21.1 KB