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) {
rt, indir_ := indirect(origt);
// We only send structs - everything else is basic or an error
switch t := rt.(type) {
case *reflect.StructType: // TODO: when compiler handles type lists, can fold these
break; // we handle these
case *reflect.ChanType:
enc.badType(rt);
return;
case *reflect.FuncType:
enc.badType(rt);
return;
case *reflect.MapType:
enc.badType(rt);
return;
case *reflect.InterfaceType:
enc.badType(rt);
switch rt.(type) {
default:
// Basic types do not need to be described.
return;
// Array and slice types are not sent, only their element types.
// If we see one here it's user error.
case *reflect.ArrayType:
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);
return;
case *reflect.SliceType:
case *reflect.ArrayType, *reflect.SliceType:
// Array and slice types are not sent, only their element types.
// If we see one here it's user error; probably a bad top-level value.
enc.badType(rt);
return;
default:
return; // basic, not a type to be sent.
}
// 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