summaryrefslogtreecommitdiff
path: root/vendor/github.com/gogo/protobuf/proto/encode.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/gogo/protobuf/proto/encode.go')
-rw-r--r--vendor/github.com/gogo/protobuf/proto/encode.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/vendor/github.com/gogo/protobuf/proto/encode.go b/vendor/github.com/gogo/protobuf/proto/encode.go
index 8c1b8fd1f..2b30f8462 100644
--- a/vendor/github.com/gogo/protobuf/proto/encode.go
+++ b/vendor/github.com/gogo/protobuf/proto/encode.go
@@ -234,10 +234,6 @@ func Marshal(pb Message) ([]byte, error) {
}
p := NewBuffer(nil)
err := p.Marshal(pb)
- var state errorState
- if err != nil && !state.shouldContinue(err, nil) {
- return nil, err
- }
if p.buf == nil && err == nil {
// Return a non-nil slice on success.
return []byte{}, nil
@@ -266,11 +262,8 @@ func (p *Buffer) Marshal(pb Message) error {
// Can the object marshal itself?
if m, ok := pb.(Marshaler); ok {
data, err := m.Marshal()
- if err != nil {
- return err
- }
p.buf = append(p.buf, data...)
- return nil
+ return err
}
t, base, err := getbase(pb)
@@ -282,7 +275,7 @@ func (p *Buffer) Marshal(pb Message) error {
}
if collectStats {
- stats.Encode++
+ (stats).Encode++ // Parens are to work around a goimports bug.
}
if len(p.buf) > maxMarshalSize {
@@ -309,7 +302,7 @@ func Size(pb Message) (n int) {
}
if collectStats {
- stats.Size++
+ (stats).Size++ // Parens are to work around a goimports bug.
}
return
@@ -1014,7 +1007,6 @@ func size_slice_struct_message(p *Properties, base structPointer) (n int) {
if p.isMarshaler {
m := structPointer_Interface(structp, p.stype).(Marshaler)
data, _ := m.Marshal()
- n += len(p.tagcode)
n += sizeRawBytes(data)
continue
}
@@ -1083,10 +1075,17 @@ func (o *Buffer) enc_map(p *Properties, base structPointer) error {
func (o *Buffer) enc_exts(p *Properties, base structPointer) error {
exts := structPointer_Extensions(base, p.field)
- if err := encodeExtensions(exts); err != nil {
+
+ v, mu := exts.extensionsRead()
+ if v == nil {
+ return nil
+ }
+
+ mu.Lock()
+ defer mu.Unlock()
+ if err := encodeExtensionsMap(v); err != nil {
return err
}
- v, _ := exts.extensionsRead()
return o.enc_map_body(v)
}