[#1262] metabase: Optimize decodeList

Prevent additional allocation during `append` in `Put`.

```
name              old alloc/op   new alloc/op   delta
Put/parallel-8       131kB ± 1%     126kB ± 4%  -3.87%  (p=0.005 n=8+8)
Put/sequential-8     172kB ± 1%     171kB ± 1%  -0.73%  (p=0.028 n=10+9)
```

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-21 16:59:33 +03:00 committed by Alex Vanin
parent 456e1584d6
commit d45df614fb

View file

@ -379,7 +379,7 @@ func decodeList(data []byte) (lst [][]byte, err error) {
}
r := io.NewBinReaderFromBuf(data)
l := r.ReadVarUint()
lst = make([][]byte, l)
lst = make([][]byte, l, l+1)
for i := range lst {
lst[i] = r.ReadVarBytes()
}