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

thrift: allow reusing struct fields #117

Merged
merged 2 commits into from
Jan 4, 2022

Conversation

achille-roussel
Copy link
Contributor

This is a small change to allow reusing inner pointer fields of struct values in the thrift decoder. The existing implementation would always zero out the struct value before decoding it, which means pointers are set to nil and whatever object they were referencing is lost.

Most applications won't need this optimization and can allocate new objects to decode values into (they will have the zero value then). Applications that do need this optimization are aware that they must zero-out the objects they reuse across decoding operations, which makes it a meaningful change.

@kevinburkesegment
Copy link
Contributor

Applications that do need this optimization are aware that they must zero-out the objects they reuse

Where would that be noted? I guess I don't see any docs on Decoder or NewDecoder which seem like the obvious places to look.

@kevinburkesegment
Copy link
Contributor

ok LGTM

@achille-roussel
Copy link
Contributor Author

Thanks for the review!

@achille-roussel achille-roussel merged commit f3a2210 into master Jan 4, 2022
@achille-roussel achille-roussel deleted the thrift-allow-reuse-struct-fields branch January 4, 2022 19:41
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.

None yet

2 participants