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/proto/size.go b/proto/size.go
index ab00a20..1266143 100644
--- a/proto/size.go
+++ b/proto/size.go
@@ -7,6 +7,7 @@
import (
"google.golang.org/protobuf/internal/encoding/wire"
"google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/runtime/protoiface"
)
// Size returns the size in bytes of the wire-format encoding of m.
@@ -21,7 +22,7 @@
func sizeMessage(m protoreflect.Message) (size int) {
if methods := protoMethods(m); methods != nil && methods.Size != nil {
- return methods.Size(m)
+ return methods.Size(m, protoiface.MarshalOptions{})
}
return sizeMessageSlow(m)
}