v1.3.0
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 todynamic.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
toreflect.Value
), reflective operations on map fields and values use the newMapRange
method instead ofMapKeys
. This is much more efficient (less memory used, fewer allocations).
- When a
dynamic.Message
is cloned using theproto.Clone
method, the new message failed to copy an internal field (the message's associateddynamic.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 inproto.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 allowsgoogle.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 afloat
ordouble
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.