runtime/protoiface: API adjustments
The following adjustments were made:
* The pragma.NoUnkeyedLiterals is moved to be the first field.
This is done to keep the options struct smaller. Even if the last
field is zero-length, Go GC implementation details forces the struct
to be padded at the end.
* Methods are documented as always treating AllowPartial as true.
* Added a support flag for UnmarshalOptions.DiscardUnknown.
Change-Id: I1f75d226542ab2bb0123d9cea143c7060df226d8
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/185998
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/encode.go b/internal/impl/encode.go
index 010d412..08daf55 100644
--- a/internal/impl/encode.go
+++ b/internal/impl/encode.go
@@ -47,14 +47,14 @@
func (o marshalOptions) UseCachedSize() bool { return o&marshalUseCachedSize != 0 }
// size is protoreflect.Methods.Size.
-func (mi *MessageInfo) size(m pref.Message) (size int) {
+func (mi *MessageInfo) size(m pref.Message, opts piface.MarshalOptions) (size int) {
var p pointer
if ms, ok := m.(*messageState); ok {
p = ms.pointer()
} else {
p = m.(*messageReflectWrapper).pointer()
}
- return mi.sizePointer(p, 0)
+ return mi.sizePointer(p, newMarshalOptions(opts))
}
func (mi *MessageInfo) sizePointer(p pointer, opts marshalOptions) (size int) {