diff options
Diffstat (limited to 'vendor/github.com/golang/protobuf/proto/properties.go')
-rw-r--r-- | vendor/github.com/golang/protobuf/proto/properties.go | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/vendor/github.com/golang/protobuf/proto/properties.go b/vendor/github.com/golang/protobuf/proto/properties.go index 50b99b8..79668ff 100644 --- a/vendor/github.com/golang/protobuf/proto/properties.go +++ b/vendor/github.com/golang/protobuf/proto/properties.go | |||
@@ -334,9 +334,6 @@ func GetProperties(t reflect.Type) *StructProperties { | |||
334 | sprop, ok := propertiesMap[t] | 334 | sprop, ok := propertiesMap[t] |
335 | propertiesMu.RUnlock() | 335 | propertiesMu.RUnlock() |
336 | if ok { | 336 | if ok { |
337 | if collectStats { | ||
338 | stats.Chit++ | ||
339 | } | ||
340 | return sprop | 337 | return sprop |
341 | } | 338 | } |
342 | 339 | ||
@@ -346,17 +343,20 @@ func GetProperties(t reflect.Type) *StructProperties { | |||
346 | return sprop | 343 | return sprop |
347 | } | 344 | } |
348 | 345 | ||
346 | type ( | ||
347 | oneofFuncsIface interface { | ||
348 | XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) | ||
349 | } | ||
350 | oneofWrappersIface interface { | ||
351 | XXX_OneofWrappers() []interface{} | ||
352 | } | ||
353 | ) | ||
354 | |||
349 | // getPropertiesLocked requires that propertiesMu is held. | 355 | // getPropertiesLocked requires that propertiesMu is held. |
350 | func getPropertiesLocked(t reflect.Type) *StructProperties { | 356 | func getPropertiesLocked(t reflect.Type) *StructProperties { |
351 | if prop, ok := propertiesMap[t]; ok { | 357 | if prop, ok := propertiesMap[t]; ok { |
352 | if collectStats { | ||
353 | stats.Chit++ | ||
354 | } | ||
355 | return prop | 358 | return prop |
356 | } | 359 | } |
357 | if collectStats { | ||
358 | stats.Cmiss++ | ||
359 | } | ||
360 | 360 | ||
361 | prop := new(StructProperties) | 361 | prop := new(StructProperties) |
362 | // in case of recursive protos, fill this in now. | 362 | // in case of recursive protos, fill this in now. |
@@ -391,13 +391,14 @@ func getPropertiesLocked(t reflect.Type) *StructProperties { | |||
391 | // Re-order prop.order. | 391 | // Re-order prop.order. |
392 | sort.Sort(prop) | 392 | sort.Sort(prop) |
393 | 393 | ||
394 | type oneofMessage interface { | 394 | var oots []interface{} |
395 | XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) | 395 | switch m := reflect.Zero(reflect.PtrTo(t)).Interface().(type) { |
396 | case oneofFuncsIface: | ||
397 | _, _, _, oots = m.XXX_OneofFuncs() | ||
398 | case oneofWrappersIface: | ||
399 | oots = m.XXX_OneofWrappers() | ||
396 | } | 400 | } |
397 | if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { | 401 | if len(oots) > 0 { |
398 | var oots []interface{} | ||
399 | _, _, _, oots = om.XXX_OneofFuncs() | ||
400 | |||
401 | // Interpret oneof metadata. | 402 | // Interpret oneof metadata. |
402 | prop.OneofTypes = make(map[string]*OneofProperties) | 403 | prop.OneofTypes = make(map[string]*OneofProperties) |
403 | for _, oot := range oots { | 404 | for _, oot := range oots { |