Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go] Fix for decoding into a struct with pre-allocated slices. #825

Merged
merged 3 commits into from
Dec 13, 2020

Conversation

ethanf
Copy link
Contributor

@ethanf ethanf commented Dec 13, 2020

This change allows you to call Decode() on an sbe struct where the struct has pre-allocated slices. Before, the code would allocate a new slice if the capacity on the existing slice was less than the number of groups in the message. If the old slice had a greater capacity, it wouldn't truncate the number of elements to the new length. The same issue with vardata fields.

This change allows you to call `Decode()` on an sbe struct where the struct has
pre-allocated slices. Before, the code would allocate a new slice if the
capacity on the existing slice was less than the number of groups in the
message. If the old slice had a greater capacity, it wouldn't truncate the
number of elements to the new length.
This tests that if the existing decoded struct has a vardata value with
length = 5, and the message to decode has length = 4, then the vardata
value is truncated to length 4.
@ethanf ethanf changed the title Fix for decoding into a struct with pre-allocated slices. [Go] Fix for decoding into a struct with pre-allocated slices. Dec 13, 2020
@ethanf
Copy link
Contributor Author

ethanf commented Dec 13, 2020

@billsegall can you have a look?

@billsegall
Copy link
Contributor

I like it. It's a neat fix.

@mjpt777 mjpt777 merged commit fa12de2 into aeron-io:master Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants