Skip to content

Commit

Permalink
thrift: allow reusing struct fields (#117)
Browse files Browse the repository at this point in the history
* thrift: allow reusing struct fields

* update documentation
  • Loading branch information
Achille committed Jan 4, 2022
1 parent 04dfa1a commit f3a2210
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion thrift/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import (
// The function errors if the data in b does not match the type of v.
//
// The function panics if v cannot be converted to a thrift representation.
//
// As an optimization, the value passed in v may be reused across multiple calls
// to Unmarshal, allowing the function to reuse objects referenced by pointer
// fields of struct values. When reusing objects, the application is responsible
// for resetting the state of v before calling Unmarshal again.
func Unmarshal(p Protocol, b []byte, v interface{}) error {
br := bytes.NewReader(b)
pr := p.NewReader(br)
Expand Down Expand Up @@ -347,7 +352,6 @@ type structDecoder struct {
}

func (dec *structDecoder) decode(r Reader, v reflect.Value, flags flags) error {
v.Set(dec.zero)
flags = flags.only(decodeFlags)
coalesceBoolFields := flags.have(coalesceBoolFields)

Expand Down

0 comments on commit f3a2210

Please sign in to comment.