mirror of https://github.com/goccy/go-json.git
Add noescape trick for decoding
This commit is contained in:
parent
df0365d82f
commit
a979b83d27
|
@ -81,7 +81,10 @@ func (d *Decoder) decode(src []byte, header *interfaceHeader) error {
|
|||
typeptr := uintptr(unsafe.Pointer(typ))
|
||||
dec := cachedDecoder.get(typeptr)
|
||||
if dec == nil {
|
||||
compiledDec, err := d.compileHead(typ)
|
||||
// noescape trick for header.typ ( reflect.*rtype )
|
||||
copiedType := (*rtype)(unsafe.Pointer(typeptr))
|
||||
|
||||
compiledDec, err := d.compileHead(copiedType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ func (e *Encoder) encode(v interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// to noescape trick for header.typ ( reflect.*rtype )
|
||||
// noescape trick for header.typ ( reflect.*rtype )
|
||||
copiedType := (*rtype)(unsafe.Pointer(typeptr))
|
||||
|
||||
codeIndent, err := e.compileHead(copiedType, true)
|
||||
|
|
Loading…
Reference in New Issue