internal/impl: use XXX_unrecognized exclusively for unknown fields
The protobuf data model makes no distinction between unknown fields
that are within the extension field ranges or not. Now that we eagerly
unmarshal extensions, there is even less need for storing unknown
fields in the extension map. Instead, use the XXX_unrecognized field
exclusively for this purpose.
Change-Id: I673a7d6259fe9fdbdc295bcfa8252ef4da415343
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/175579
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/legacy_extension.go b/internal/impl/legacy_extension.go
index e187127..9ea5b0a 100644
--- a/internal/impl/legacy_extension.go
+++ b/internal/impl/legacy_extension.go
@@ -183,12 +183,7 @@
if x.Value != nil {
panic("value for extension descriptor still populated")
}
- x.Desc = nil
- if len(x.Raw) == 0 {
- p.x.Clear(t.Number())
- } else {
- p.x.Set(t.Number(), x)
- }
+ p.x.Clear(t.Number())
}
func (p legacyExtensionTypes) ByNumber(n pref.FieldNumber) pref.ExtensionType {
@@ -269,9 +264,6 @@
// The Value may only be populated if Desc is also populated.
Value interface{} // TODO: switch to protoreflect.Value
- // Raw is the raw encoded bytes for the extension field.
- // It is possible for Raw to be populated irrespective of whether the
- // other fields are populated.
Raw []byte // TODO: remove; let this be handled by XXX_unrecognized
}