@@ -21,7 +21,7 @@ type DescriptorWrapper interface {
21
21
// WrapDescriptor wraps the given descriptor, returning a desc.Descriptor
22
22
// value that represents the same element.
23
23
func WrapDescriptor (d protoreflect.Descriptor ) (Descriptor , error ) {
24
- return wrapDescriptor (d , noopCache {})
24
+ return wrapDescriptor (d , mapCache {})
25
25
}
26
26
27
27
func wrapDescriptor (d protoreflect.Descriptor , cache descriptorCache ) (Descriptor , error ) {
@@ -65,18 +65,21 @@ func WrapFiles(d []protoreflect.FileDescriptor) ([]*FileDescriptor, error) {
65
65
// WrapFile wraps the given file descriptor, returning a *desc.FileDescriptor
66
66
// value that represents the same file.
67
67
func WrapFile (d protoreflect.FileDescriptor ) (* FileDescriptor , error ) {
68
- return wrapFile (d , noopCache {})
68
+ return wrapFile (d , mapCache {})
69
69
}
70
70
71
71
func wrapFile (d protoreflect.FileDescriptor , cache descriptorCache ) (* FileDescriptor , error ) {
72
+ if res := cache .get (d ); res != nil {
73
+ return res .(* FileDescriptor ), nil
74
+ }
72
75
fdp := protoutil .ProtoFromFileDescriptor (d )
73
76
return convertFile (d , fdp , cache )
74
77
}
75
78
76
79
// WrapMessage wraps the given message descriptor, returning a *desc.MessageDescriptor
77
80
// value that represents the same message.
78
81
func WrapMessage (d protoreflect.MessageDescriptor ) (* MessageDescriptor , error ) {
79
- return wrapMessage (d , noopCache {})
82
+ return wrapMessage (d , mapCache {})
80
83
}
81
84
82
85
func wrapMessage (d protoreflect.MessageDescriptor , cache descriptorCache ) (* MessageDescriptor , error ) {
@@ -97,7 +100,7 @@ func wrapMessage(d protoreflect.MessageDescriptor, cache descriptorCache) (*Mess
97
100
// WrapField wraps the given field descriptor, returning a *desc.FieldDescriptor
98
101
// value that represents the same field.
99
102
func WrapField (d protoreflect.FieldDescriptor ) (* FieldDescriptor , error ) {
100
- return wrapField (d , noopCache {})
103
+ return wrapField (d , mapCache {})
101
104
}
102
105
103
106
func wrapField (d protoreflect.FieldDescriptor , cache descriptorCache ) (* FieldDescriptor , error ) {
@@ -121,7 +124,7 @@ func wrapField(d protoreflect.FieldDescriptor, cache descriptorCache) (*FieldDes
121
124
// WrapOneOf wraps the given oneof descriptor, returning a *desc.OneOfDescriptor
122
125
// value that represents the same oneof.
123
126
func WrapOneOf (d protoreflect.OneofDescriptor ) (* OneOfDescriptor , error ) {
124
- return wrapOneOf (d , noopCache {})
127
+ return wrapOneOf (d , mapCache {})
125
128
}
126
129
127
130
func wrapOneOf (d protoreflect.OneofDescriptor , cache descriptorCache ) (* OneOfDescriptor , error ) {
@@ -138,7 +141,7 @@ func wrapOneOf(d protoreflect.OneofDescriptor, cache descriptorCache) (*OneOfDes
138
141
// WrapEnum wraps the given enum descriptor, returning a *desc.EnumDescriptor
139
142
// value that represents the same enum.
140
143
func WrapEnum (d protoreflect.EnumDescriptor ) (* EnumDescriptor , error ) {
141
- return wrapEnum (d , noopCache {})
144
+ return wrapEnum (d , mapCache {})
142
145
}
143
146
144
147
func wrapEnum (d protoreflect.EnumDescriptor , cache descriptorCache ) (* EnumDescriptor , error ) {
@@ -159,7 +162,7 @@ func wrapEnum(d protoreflect.EnumDescriptor, cache descriptorCache) (*EnumDescri
159
162
// WrapEnumValue wraps the given enum value descriptor, returning a *desc.EnumValueDescriptor
160
163
// value that represents the same enum value.
161
164
func WrapEnumValue (d protoreflect.EnumValueDescriptor ) (* EnumValueDescriptor , error ) {
162
- return wrapEnumValue (d , noopCache {})
165
+ return wrapEnumValue (d , mapCache {})
163
166
}
164
167
165
168
func wrapEnumValue (d protoreflect.EnumValueDescriptor , cache descriptorCache ) (* EnumValueDescriptor , error ) {
@@ -176,7 +179,7 @@ func wrapEnumValue(d protoreflect.EnumValueDescriptor, cache descriptorCache) (*
176
179
// WrapService wraps the given service descriptor, returning a *desc.ServiceDescriptor
177
180
// value that represents the same service.
178
181
func WrapService (d protoreflect.ServiceDescriptor ) (* ServiceDescriptor , error ) {
179
- return wrapService (d , noopCache {})
182
+ return wrapService (d , mapCache {})
180
183
}
181
184
182
185
func wrapService (d protoreflect.ServiceDescriptor , cache descriptorCache ) (* ServiceDescriptor , error ) {
@@ -193,7 +196,7 @@ func wrapService(d protoreflect.ServiceDescriptor, cache descriptorCache) (*Serv
193
196
// WrapMethod wraps the given method descriptor, returning a *desc.MethodDescriptor
194
197
// value that represents the same method.
195
198
func WrapMethod (d protoreflect.MethodDescriptor ) (* MethodDescriptor , error ) {
196
- return wrapMethod (d , noopCache {})
199
+ return wrapMethod (d , mapCache {})
197
200
}
198
201
199
202
func wrapMethod (d protoreflect.MethodDescriptor , cache descriptorCache ) (* MethodDescriptor , error ) {
0 commit comments