mirror of https://github.com/golang/go.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
This commit is contained in:
parent
aa69a3c386
commit
fdaeec580f
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue