]> Cypherpunks repositories - gostls13.git/commitdiff
improve some type switches now that multiple types per case are supported.
authorRob Pike <r@golang.org>
Tue, 29 Dec 2009 21:33:48 +0000 (08:33 +1100)
committerRob Pike <r@golang.org>
Tue, 29 Dec 2009 21:33:48 +0000 (08:33 +1100)
R=rsc
CC=golang-dev
https://golang.org/cl/181089

src/pkg/gob/decode.go
src/pkg/gob/type.go

index 41951d357f5fe98434f83c2ffd896c0bc0f660d1..88bc65d62189f644e82e76a103eb7418ff0f1964 100644 (file)
@@ -630,33 +630,11 @@ func (dec *Decoder) compatibleType(fr reflect.Type, fw typeId) bool {
                return false
        case *reflect.BoolType:
                return fw == tBool
-       case *reflect.IntType:
+       case *reflect.IntType, *reflect.Int8Type, *reflect.Int16Type, *reflect.Int32Type, *reflect.Int64Type:
                return fw == tInt
-       case *reflect.Int8Type:
-               return fw == tInt
-       case *reflect.Int16Type:
-               return fw == tInt
-       case *reflect.Int32Type:
-               return fw == tInt
-       case *reflect.Int64Type:
-               return fw == tInt
-       case *reflect.UintType:
-               return fw == tUint
-       case *reflect.Uint8Type:
-               return fw == tUint
-       case *reflect.Uint16Type:
+       case *reflect.UintType, *reflect.Uint8Type, *reflect.Uint16Type, *reflect.Uint32Type, *reflect.Uint64Type, *reflect.UintptrType:
                return fw == tUint
-       case *reflect.Uint32Type:
-               return fw == tUint
-       case *reflect.Uint64Type:
-               return fw == tUint
-       case *reflect.UintptrType:
-               return fw == tUint
-       case *reflect.FloatType:
-               return fw == tFloat
-       case *reflect.Float32Type:
-               return fw == tFloat
-       case *reflect.Float64Type:
+       case *reflect.FloatType, *reflect.Float32Type, *reflect.Float64Type:
                return fw == tFloat
        case *reflect.StringType:
                return fw == tString
index 58ed96b32fa7abaedb9e2ae2c3136fdc33124559..2ffdfc6a1a700d1cc02665ab658454455195abac 100644 (file)
@@ -212,35 +212,13 @@ func newTypeObject(name string, rt reflect.Type) (gobType, os.Error) {
        case *reflect.BoolType:
                return tBool.gobType(), nil
 
-       case *reflect.IntType:
-               return tInt.gobType(), nil
-       case *reflect.Int8Type:
-               return tInt.gobType(), nil
-       case *reflect.Int16Type:
-               return tInt.gobType(), nil
-       case *reflect.Int32Type:
-               return tInt.gobType(), nil
-       case *reflect.Int64Type:
+       case *reflect.IntType, *reflect.Int8Type, *reflect.Int16Type, *reflect.Int32Type, *reflect.Int64Type:
                return tInt.gobType(), nil
 
-       case *reflect.UintType:
-               return tUint.gobType(), nil
-       case *reflect.Uint8Type:
-               return tUint.gobType(), nil
-       case *reflect.Uint16Type:
-               return tUint.gobType(), nil
-       case *reflect.Uint32Type:
-               return tUint.gobType(), nil
-       case *reflect.Uint64Type:
-               return tUint.gobType(), nil
-       case *reflect.UintptrType:
+       case *reflect.UintType, *reflect.Uint8Type, *reflect.Uint16Type, *reflect.Uint32Type, *reflect.Uint64Type, *reflect.UintptrType:
                return tUint.gobType(), nil
 
-       case *reflect.FloatType:
-               return tFloat.gobType(), nil
-       case *reflect.Float32Type:
-               return tFloat.gobType(), nil
-       case *reflect.Float64Type:
+       case *reflect.FloatType, *reflect.Float32Type, *reflect.Float64Type:
                return tFloat.gobType(), nil
 
        case *reflect.StringType: