Commit facd79e4 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

encoding/binary: cull dead code

Change-Id: I91f9b5280e08e005f5a891aaa249267c211d814b
Reviewed-on: https://go-review.googlesource.com/7592Reviewed-by: default avatarMinux Ma <minux@golang.org>
parent 5158147e
...@@ -239,78 +239,62 @@ func Write(w io.Writer, order ByteOrder, data interface{}) error { ...@@ -239,78 +239,62 @@ func Write(w io.Writer, order ByteOrder, data interface{}) error {
} }
switch v := data.(type) { switch v := data.(type) {
case *int8: case *int8:
bs = b[:1]
b[0] = byte(*v) b[0] = byte(*v)
case int8: case int8:
bs = b[:1]
b[0] = byte(v) b[0] = byte(v)
case []int8: case []int8:
for i, x := range v { for i, x := range v {
bs[i] = byte(x) bs[i] = byte(x)
} }
case *uint8: case *uint8:
bs = b[:1]
b[0] = *v b[0] = *v
case uint8: case uint8:
bs = b[:1]
b[0] = byte(v) b[0] = byte(v)
case []uint8: case []uint8:
bs = v bs = v
case *int16: case *int16:
bs = b[:2]
order.PutUint16(bs, uint16(*v)) order.PutUint16(bs, uint16(*v))
case int16: case int16:
bs = b[:2]
order.PutUint16(bs, uint16(v)) order.PutUint16(bs, uint16(v))
case []int16: case []int16:
for i, x := range v { for i, x := range v {
order.PutUint16(bs[2*i:], uint16(x)) order.PutUint16(bs[2*i:], uint16(x))
} }
case *uint16: case *uint16:
bs = b[:2]
order.PutUint16(bs, *v) order.PutUint16(bs, *v)
case uint16: case uint16:
bs = b[:2]
order.PutUint16(bs, v) order.PutUint16(bs, v)
case []uint16: case []uint16:
for i, x := range v { for i, x := range v {
order.PutUint16(bs[2*i:], x) order.PutUint16(bs[2*i:], x)
} }
case *int32: case *int32:
bs = b[:4]
order.PutUint32(bs, uint32(*v)) order.PutUint32(bs, uint32(*v))
case int32: case int32:
bs = b[:4]
order.PutUint32(bs, uint32(v)) order.PutUint32(bs, uint32(v))
case []int32: case []int32:
for i, x := range v { for i, x := range v {
order.PutUint32(bs[4*i:], uint32(x)) order.PutUint32(bs[4*i:], uint32(x))
} }
case *uint32: case *uint32:
bs = b[:4]
order.PutUint32(bs, *v) order.PutUint32(bs, *v)
case uint32: case uint32:
bs = b[:4]
order.PutUint32(bs, v) order.PutUint32(bs, v)
case []uint32: case []uint32:
for i, x := range v { for i, x := range v {
order.PutUint32(bs[4*i:], x) order.PutUint32(bs[4*i:], x)
} }
case *int64: case *int64:
bs = b[:8]
order.PutUint64(bs, uint64(*v)) order.PutUint64(bs, uint64(*v))
case int64: case int64:
bs = b[:8]
order.PutUint64(bs, uint64(v)) order.PutUint64(bs, uint64(v))
case []int64: case []int64:
for i, x := range v { for i, x := range v {
order.PutUint64(bs[8*i:], uint64(x)) order.PutUint64(bs[8*i:], uint64(x))
} }
case *uint64: case *uint64:
bs = b[:8]
order.PutUint64(bs, *v) order.PutUint64(bs, *v)
case uint64: case uint64:
bs = b[:8]
order.PutUint64(bs, v) order.PutUint64(bs, v)
case []uint64: case []uint64:
for i, x := range v { for i, x := range v {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment