summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2014-08-03 15:14:59 -0700
committerRob Pike <r@golang.org>2014-08-03 15:14:59 -0700
commit4c3c4c82ad4ab5d6525cb813e80341642bdb93e4 (patch)
tree86436bd410bc65ae0e38161bb3386911cc0b5dd4 /src
parent78f5236cf7c6636c1fd56bbdbd448c54503ef8b2 (diff)
downloadgo-4c3c4c82ad4ab5d6525cb813e80341642bdb93e4.tar.gz
encoding/gob: save a call to userType
Avoid some pressure on the global mutex by lifting the call to userType out of the closure. TOTH to Matt Harden. LGTM=crawshaw, ruiu R=golang-codereviews, crawshaw, ruiu CC=golang-codereviews https://codereview.appspot.com/117520043
Diffstat (limited to 'src')
-rw-r--r--src/pkg/encoding/gob/decode.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pkg/encoding/gob/decode.go b/src/pkg/encoding/gob/decode.go
index 76274a0ca..2367650c8 100644
--- a/src/pkg/encoding/gob/decode.go
+++ b/src/pkg/encoding/gob/decode.go
@@ -747,13 +747,14 @@ func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string, inProg
case reflect.Struct:
// Generate a closure that calls out to the engine for the nested type.
- enginePtr, err := dec.getDecEnginePtr(wireId, userType(typ))
+ ut := userType(typ)
+ enginePtr, err := dec.getDecEnginePtr(wireId, ut)
if err != nil {
error_(err)
}
op = func(i *decInstr, state *decoderState, value reflect.Value) {
// indirect through enginePtr to delay evaluation for recursive structs.
- dec.decodeStruct(*enginePtr, userType(typ), value)
+ dec.decodeStruct(*enginePtr, ut, value)
}
case reflect.Interface:
op = func(i *decInstr, state *decoderState, value reflect.Value) {