mirror of
https://github.com/golang/go.git
synced 2025-11-02 01:30:55 +00:00
reflect: add Type.Bits method, add tags to prohibit conversions
gob: substitute slice for map R=r CC=golang-dev https://golang.org/cl/1699045
This commit is contained in:
parent
2fc0b4f01b
commit
fc090a3a54
9 changed files with 112 additions and 144 deletions
|
|
@ -601,7 +601,7 @@ func encodeMap(b *bytes.Buffer, rt reflect.Type, p uintptr, keyOp, elemOp encOp,
|
|||
return state.err
|
||||
}
|
||||
|
||||
var encOpMap = map[reflect.Kind]encOp{
|
||||
var encOpMap = []encOp{
|
||||
reflect.Bool: encBool,
|
||||
reflect.Int: encInt,
|
||||
reflect.Int8: encInt8,
|
||||
|
|
@ -624,8 +624,12 @@ var encOpMap = map[reflect.Kind]encOp{
|
|||
// the indirection count to reach it.
|
||||
func encOpFor(rt reflect.Type) (encOp, int, os.Error) {
|
||||
typ, indir := indirect(rt)
|
||||
op, ok := encOpMap[typ.Kind()]
|
||||
if !ok {
|
||||
var op encOp
|
||||
k := typ.Kind()
|
||||
if int(k) < len(encOpMap) {
|
||||
op = encOpMap[k]
|
||||
}
|
||||
if op == nil {
|
||||
// Special cases
|
||||
switch t := typ.(type) {
|
||||
case *reflect.SliceType:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue