Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Conversation

@dolmen
Copy link
Contributor

@dolmen dolmen commented Apr 27, 2022

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:]

dolmen added 3 commits April 27, 2022 22:49
Allocate arrays in one block in lhef.NewDecoder.
When decoding an event block, allocate memory for slices in bigger
blocks to reduce the number of memory allocations.
Copy link
Member

@sbinet sbinet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

thanks for improving this. (it feels like good old FORTRAN column blocks, but hey :P)

@sbinet sbinet merged commit 1992369 into go-hep:main May 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants