From: Rob Pike Date: Sun, 3 Aug 2014 22:14:59 +0000 (-0700) Subject: encoding/gob: save a call to userType X-Git-Tag: go1.4beta1~962 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fdaeec580ffb554b7314f814eaa2353459b1e400;p=gostls13.git 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://golang.org/cl/117520043 --- diff --git a/src/pkg/encoding/gob/decode.go b/src/pkg/encoding/gob/decode.go index 76274a0cac..2367650c8b 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) {