From 0472aebe510c9b0641fa1f27e2688d889132a070 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 27 Nov 2021 22:24:05 +0900 Subject: [PATCH] refactor --- internal/encoder/compiler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/encoder/compiler.go b/internal/encoder/compiler.go index cd551a0..5a50fd2 100644 --- a/internal/encoder/compiler.go +++ b/internal/encoder/compiler.go @@ -85,6 +85,9 @@ func (c *Compiler) compile(typeptr uintptr) (*OpcodeSet, error) { structTypeToCodes: map[uintptr]Opcodes{}, recursiveCodes: &Opcodes{}, }, code) + if err := noescapeKeyCode.Validate(); err != nil { + return nil, err + } escapeKeyCode := c.codeToOpcode(&compileContext{ typ: typ, structTypeToCodes: map[uintptr]Opcodes{}, @@ -405,7 +408,7 @@ func (c *Compiler) marshalJSONCode(typ *runtime.Type) (*MarshalJSONCode, error) func (c *Compiler) marshalTextCode(typ *runtime.Type) (*MarshalTextCode, error) { return &MarshalTextCode{ typ: typ, - isAddrForMarshaler: !typ.Implements(marshalTextType) && runtime.PtrTo(typ).Implements(marshalTextType), + isAddrForMarshaler: c.isPtrMarshalTextType(typ), isNilableType: c.isNilableType(typ), }, nil }