Encode and decode empty bytes fields correctly.
R=r, dsymonds, rsc
CC=golang-dev
http://codereview.appspot.com/3274043
diff --git a/proto/decode.go b/proto/decode.go
index 5ad6625..1019d2a 100644
--- a/proto/decode.go
+++ b/proto/decode.go
@@ -479,10 +479,7 @@
if err != nil {
return err
}
- lb := len(b)
- if lb == 0 {
- return nil
- }
+
x := (*[]uint8)(unsafe.Pointer(base + p.offset))
y := *x
@@ -494,6 +491,7 @@
}
l := len(y)
+ lb := len(b)
if l+lb > c {
// incremental growth is max(len(slice)*1.5, len(slice)+len(bytes))
g := l * 3 / 2