1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:24:45 -07:00

improve some type switches now that multiple types per case are supported.

R=rsc
CC=golang-dev
https://golang.org/cl/181089
This commit is contained in:
Rob Pike 2009-12-30 08:33:48 +11:00
parent e01459f567
commit a58b69e1d0
2 changed files with 6 additions and 50 deletions

View 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:
case *reflect.UintType, *reflect.Uint8Type, *reflect.Uint16Type, *reflect.Uint32Type, *reflect.Uint64Type, *reflect.UintptrType:
return fw == tUint
case *reflect.Uint8Type:
return fw == tUint
case *reflect.Uint16Type:
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

View 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: