summaryrefslogtreecommitdiff
path: root/src/pkg/gob/decoder.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2010-06-29 10:14:32 -0700
committerRob Pike <r@golang.org>2010-06-29 10:14:32 -0700
commitf041c47f75a563fc83cc2129ef9fbf7e5ca56c08 (patch)
treea9c2eb61a686f37611e9fa487dfcd347245c4adf /src/pkg/gob/decoder.go
parentb4b3a37d22e0d6b403c2cb071ff96218b5e22bbb (diff)
downloadgolang-f041c47f75a563fc83cc2129ef9fbf7e5ca56c08.tar.gz
gob: a couple of tiny simplifications using Kind()
R=rsc CC=golang-dev http://codereview.appspot.com/1695046
Diffstat (limited to 'src/pkg/gob/decoder.go')
-rw-r--r--src/pkg/gob/decoder.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pkg/gob/decoder.go b/src/pkg/gob/decoder.go
index 5ba2750d2..cf16433eb 100644
--- a/src/pkg/gob/decoder.go
+++ b/src/pkg/gob/decoder.go
@@ -55,15 +55,16 @@ func (dec *Decoder) recvType(id typeId) {
// Decode reads the next value from the connection and stores
// it in the data represented by the empty interface value.
// The value underlying e must be the correct type for the next
-// data item received, which must be a pointer.
+// data item received, and must be a pointer.
func (dec *Decoder) Decode(e interface{}) os.Error {
- // If e represents a value, the answer won't get back to the
- // caller. Make sure it's a pointer.
- if _, ok := reflect.Typeof(e).(*reflect.PtrType); !ok {
+ value := reflect.NewValue(e)
+ // If e represents a value as opposed to a pointer, the answer won't
+ // get back to the caller. Make sure it's a pointer.
+ if value.Type().Kind() != reflect.Ptr {
dec.state.err = os.ErrorString("gob: attempt to decode into a non-pointer")
return dec.state.err
}
- return dec.DecodeValue(reflect.NewValue(e))
+ return dec.DecodeValue(value)
}
// DecodeValue reads the next value from the connection and stores