Skip to content

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.

2 participants