go-hep / hep

hep is the mono repository holding all of go-hep.org/x/hep packages and tools
https://go-hep.org
BSD 3-Clause "New" or "Revised" License
230 stars 35 forks source link

lhef: reduce number of allocs in Decoder #938

Closed dolmen closed 2 years ago

dolmen commented 2 years ago

In the lhef.Decoder, allocate slices using sliced bigger chunks in order to reduce the number of allocations.

Example:

a := make([]int32, n)
b := make([]int32, n)
c := make([]int32, n)

is replaced with:

n32 := make([]int32, 3*n)
a := n32[:n:n]
b := n32[n : 2*n : 2*n]
b := n32[2*n:]