Commit f966ba1d authored by Rob Pike's avatar Rob Pike

use the new type switch multicase to clean up a little.

R=rsc
DELTA=28  (7 added, 16 deleted, 5 changed)
OCL=34487
CL=34487
parent f4ee9f13
...@@ -240,31 +240,22 @@ func (enc *Encoder) sendType(origt reflect.Type) { ...@@ -240,31 +240,22 @@ func (enc *Encoder) sendType(origt reflect.Type) {
rt, indir_ := indirect(origt); rt, indir_ := indirect(origt);
// We only send structs - everything else is basic or an error // We only send structs - everything else is basic or an error
switch t := rt.(type) { switch rt.(type) {
case *reflect.StructType: // TODO: when compiler handles type lists, can fold these default:
break; // we handle these // Basic types do not need to be described.
case *reflect.ChanType:
enc.badType(rt);
return;
case *reflect.FuncType:
enc.badType(rt);
return;
case *reflect.MapType:
enc.badType(rt);
return; return;
case *reflect.InterfaceType: case *reflect.StructType:
// Structs do need to be described.
break;
case *reflect.ChanType, *reflect.FuncType, *reflect.MapType, *reflect.InterfaceType:
// Probably a bad field in a struct.
enc.badType(rt); enc.badType(rt);
return; return;
case *reflect.ArrayType, *reflect.SliceType:
// Array and slice types are not sent, only their element types. // Array and slice types are not sent, only their element types.
// If we see one here it's user error. // If we see one here it's user error; probably a bad top-level value.
case *reflect.ArrayType:
enc.badType(rt);
return;
case *reflect.SliceType:
enc.badType(rt); enc.badType(rt);
return; return;
default:
return; // basic, not a type to be sent.
} }
// Have we already sent this type? This time we ask about the base type. // Have we already sent this type? This time we ask about the base type.
......
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