diff options
Diffstat (limited to 'src/encoding/gob/decode.go')
-rw-r--r-- | src/encoding/gob/decode.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/encoding/gob/decode.go b/src/encoding/gob/decode.go index 92d9d3ef87..645aa71c38 100644 --- a/src/encoding/gob/decode.go +++ b/src/encoding/gob/decode.go @@ -542,12 +542,12 @@ func (dec *Decoder) decodeArray(state *decoderState, value reflect.Value, elemOp } // decodeIntoValue is a helper for map decoding. -func decodeIntoValue(state *decoderState, op decOp, isPtr bool, value reflect.Value, ovfl error) reflect.Value { - instr := &decInstr{op, 0, nil, ovfl} +func decodeIntoValue(state *decoderState, op decOp, isPtr bool, value reflect.Value, instr *decInstr) reflect.Value { v := value if isPtr { v = decAlloc(value) } + op(instr, state, v) return value } @@ -564,9 +564,11 @@ func (dec *Decoder) decodeMap(mtyp reflect.Type, state *decoderState, value refl n := int(state.decodeUint()) keyIsPtr := mtyp.Key().Kind() == reflect.Ptr elemIsPtr := mtyp.Elem().Kind() == reflect.Ptr + keyInstr := &decInstr{keyOp, 0, nil, ovfl} + elemInstr := &decInstr{elemOp, 0, nil, ovfl} for i := 0; i < n; i++ { - key := decodeIntoValue(state, keyOp, keyIsPtr, allocValue(mtyp.Key()), ovfl) - elem := decodeIntoValue(state, elemOp, elemIsPtr, allocValue(mtyp.Elem()), ovfl) + key := decodeIntoValue(state, keyOp, keyIsPtr, allocValue(mtyp.Key()), keyInstr) + elem := decodeIntoValue(state, elemOp, elemIsPtr, allocValue(mtyp.Elem()), elemInstr) value.SetMapIndex(key, elem) } } |