Skip to content

v1.3.0

Compare
Choose a tag to compare
@jhump jhump released this 20 May 18:36
7dce9ca

This release is mostly bug fixes and performance improvements to various packages. Though it does also include minor API addition to the dynamic package.

"github.com/jhump/protoreflect/dynamic"

Additions:

  • A new MarshalAppend method was added to dynamic.Message, which gives caller more control over allocation of byte slices.

Changes/fixes:

  • Numerous small performance improvements were made:
    • Setting values on a dynamic message would eagerly allocate and construct strings that were only used when errors were encountered. This is no longer done; strings are not allocated/computed until error actually occurs. This greatly reduces the number of allocations during de-serialization of messages.
    • When a dynamic message was cleared, its internal maps were set to nil. Now they are instead cleared (e.g. every key+value removed) so that they do not need to be re-allocated when the message is re-used.
    • When using Go 1.12 (which introduced MapRange to reflect.Value), reflective operations on map fields and values use the new MapRange method instead of MapKeys. This is much more efficient (less memory used, fewer allocations).
  • When a dynamic.Message is cloned using the proto.Clone method, the new message failed to copy an internal field (the message's associated dynamic.MessageFactory. This could cause strange behavior during de-serialization, where construction of nested message objects in the clone would vary from the source message.
  • Two dynamic.Message instances, for messages defined in "proto2" syntax, would previously be considered not equal if one of them had no value for a repeated or map field but the other had an explicitly empty value. However, for protobufs (and as implemented in proto.Equal), empty and unset map and repeated values should be indistinguishable. This was fixed.
  • Support was added to dynamic.Message for parsing "extended Any syntax" in the text format. This format allows google.protobuf.Any messages to be represented in a much more readable manner, where the embedded message value uses the text format (instead of being represented as bytes in the binary format).
  • A dynamic.Message with a float or double field with an infinite or NaN value could not be correctly marshaled to JSON. No error would occur, but the resulting JSON output would be invalid and un-parseable. This has been remedied.
  • A dynamic.Message could not be unmarshaled via the text format if the text data included an infinite or NaN value. This has also been remedied.

"github.com/jhump/protoreflect/desc/protoparse"

Changes/fixes:

  • Attempting to parse an empty file (or a file with only whitespace) would result in a panic. Now it returns an error.