summaryrefslogtreecommitdiff
path: root/src/pkg/gob/encode.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/gob/encode.go')
-rw-r--r--src/pkg/gob/encode.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/pkg/gob/encode.go b/src/pkg/gob/encode.go
index 93f9e509b..76032389e 100644
--- a/src/pkg/gob/encode.go
+++ b/src/pkg/gob/encode.go
@@ -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: