From 4c3c4c82ad4ab5d6525cb813e80341642bdb93e4 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sun, 3 Aug 2014 15:14:59 -0700 Subject: 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 --- src/pkg/encoding/gob/decode.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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) { -- cgit v1.2.1