internal/filedesc: use jsonName.Init method over JSONName constructor
The JSONName constructor returns a struct value which shallow copies
a sync.Once within it; this is a dubious pattern.
Instead, add a jsonName.Init method to initialize the value.
Change-Id: I190a7239b1b62a8041ee7e4e09c0fe37b64ff623
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/213237
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/filedesc/desc_lazy.go b/internal/filedesc/desc_lazy.go
index 309d739..c43b3e2 100644
--- a/internal/filedesc/desc_lazy.go
+++ b/internal/filedesc/desc_lazy.go
@@ -449,7 +449,7 @@
case fieldnum.FieldDescriptorProto_Name:
fd.L0.FullName = appendFullName(sb, pd.FullName(), v)
case fieldnum.FieldDescriptorProto_JsonName:
- fd.L1.JSONName = JSONName(sb.MakeString(v))
+ fd.L1.JSONName.Init(sb.MakeString(v))
case fieldnum.FieldDescriptorProto_DefaultValue:
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
case fieldnum.FieldDescriptorProto_TypeName:
@@ -542,7 +542,7 @@
b = b[m:]
switch num {
case fieldnum.FieldDescriptorProto_JsonName:
- xd.L2.JSONName = JSONName(sb.MakeString(v))
+ xd.L2.JSONName.Init(sb.MakeString(v))
case fieldnum.FieldDescriptorProto_DefaultValue:
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
case fieldnum.FieldDescriptorProto_TypeName: