aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/gob/decode.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/encoding/gob/decode.go b/src/encoding/gob/decode.go
index 28ceb5a0cf..bffe45a72a 100644
--- a/src/encoding/gob/decode.go
+++ b/src/encoding/gob/decode.go
@@ -601,15 +601,13 @@ func (dec *Decoder) decodeMap(mtyp reflect.Type, state *decoderState, value refl
keyInstr := &decInstr{keyOp, 0, nil, ovfl}
elemInstr := &decInstr{elemOp, 0, nil, ovfl}
keyP := reflect.New(mtyp.Key())
- keyZ := reflect.Zero(mtyp.Key())
elemP := reflect.New(mtyp.Elem())
- elemZ := reflect.Zero(mtyp.Elem())
for i := 0; i < n; i++ {
key := decodeIntoValue(state, keyOp, keyIsPtr, keyP.Elem(), keyInstr)
elem := decodeIntoValue(state, elemOp, elemIsPtr, elemP.Elem(), elemInstr)
value.SetMapIndex(key, elem)
- keyP.Elem().Set(keyZ)
- elemP.Elem().Set(elemZ)
+ keyP.Elem().SetZero()
+ elemP.Elem().SetZero()
}
}
@@ -692,7 +690,7 @@ func (dec *Decoder) decodeInterface(ityp reflect.Type, state *decoderState, valu
// Allocate the destination interface value.
if len(name) == 0 {
// Copy the nil interface value to the target.
- value.Set(reflect.Zero(value.Type()))
+ value.SetZero()
return
}
if len(name) > 1024 {