internal/impl: simplify extension data structures
The v2 implementation will eagerly unmarshal extension fields,
which means that the logic to synchronize the extensions fields
is no longer necessary. Using type aliases, we can ensure
impl.ExtensionsV1 is identical to the extensions map prior to
a4ab9ec5 from May 2016. This makes it such that we only have one
legacy implementation that we have to deal with.
Change-Id: I41b977e912fbb899c5bc4f055890d474b419429c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/172240
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/legacy_export.go b/internal/impl/legacy_export.go
index 44bb101..d40d4ff 100644
--- a/internal/impl/legacy_export.go
+++ b/internal/impl/legacy_export.go
@@ -79,14 +79,12 @@
// ExtensionFieldsOf returns an interface abstraction over various
// internal representations of extension fields.
//
-// TODO: Delete this once v1 no longer needs to interact with the low-level
-// extensions data structure.
+// TODO: Delete this once v1 no longer needs this.
+// Remember to delete the HasInit, Lock, and Unlock methods.
func (Export) ExtensionFieldsOf(p interface{}) legacyExtensionFieldsIface {
switch p := p.(type) {
- case *map[int32]ExtensionFieldV1:
- return (*legacyExtensionMap)(p)
case *ExtensionFieldsV1:
- return (*legacyExtensionSyncMap)(p)
+ return (*legacyExtensionMap)(p)
default:
panic(fmt.Sprintf("invalid extension fields type: %T", p))
}