Use NoEscapedString

This commit is contained in:
Masaaki Goshima 2021-01-11 19:47:33 +09:00
parent af9168203a
commit 135a3c0cfb
2 changed files with 4 additions and 8 deletions

View File

@ -301,11 +301,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
if err != nil { if err != nil {
return nil, errMarshaler(code, err) return nil, errMarshaler(code, err)
} }
if e.enabledHTMLEscape {
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
} else {
b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
}
b = encodeComma(b) b = encodeComma(b)
} }
code = code.next code = code.next
@ -3501,7 +3497,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
} }
} }
b = append(b, code.key...) b = append(b, code.key...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
} }
@ -3532,7 +3528,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
} }
} }
b = append(b, code.key...) b = append(b, code.key...)
b = encodeEscapedString(b, *(*string)(unsafe.Pointer(&bytes))) b = encodeNoEscapedString(b, *(*string)(unsafe.Pointer(&bytes)))
b = encodeComma(b) b = encodeComma(b)
code = code.next code = code.next
} }

View File

@ -4165,7 +4165,7 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil { if err := compact(&buf, bb, e.enabledHTMLEscape); err != nil {
return nil, err return nil, err
} }
b = encodeEscapedString(b, buf.String()) b = encodeNoEscapedString(b, buf.String())
b = encodeIndentComma(b) b = encodeIndentComma(b)
code = code.next code = code.next
case opStructFieldStringTagMarshalText: case opStructFieldStringTagMarshalText: