internal/impl: avoid type conversion on UnmarshalOptions.Resolver
Remove a trivial difference in the definition of the resolver
unmarshaler option to avoid a relatively expensive interface->interface
type conversion.
Change-Id: Iecf9a686af5d17fe3e2d9b80f886c644bf8a25df
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/215657
Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/internal/impl/decode.go b/internal/impl/decode.go
index 5bce77a..3e26223 100644
--- a/internal/impl/decode.go
+++ b/internal/impl/decode.go
@@ -19,8 +19,13 @@
// We don't preserve the AllowPartial flag, because fast-path (un)marshal
// operations always allow partial messages.
type unmarshalOptions struct {
- flags unmarshalOptionFlags
- resolver preg.ExtensionTypeResolver
+ flags unmarshalOptionFlags
+
+ // Keep this field's type identical to (proto.UnmarshalOptions).Resolver
+ // to avoid a type conversion on assignment.
+ resolver interface {
+ preg.ExtensionTypeResolver
+ }
}
type unmarshalOptionFlags uint8