From f041c47f75a563fc83cc2129ef9fbf7e5ca56c08 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Tue, 29 Jun 2010 10:14:32 -0700 Subject: gob: a couple of tiny simplifications using Kind() R=rsc CC=golang-dev http://codereview.appspot.com/1695046 --- src/pkg/gob/decoder.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/pkg/gob/decoder.go') 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 -- cgit v1.2.3