mirror of https://github.com/goccy/go-json.git
Improve performance for []byte type
This commit is contained in:
parent
6681db131f
commit
e28091e4c7
|
@ -74,9 +74,12 @@ func (e *Encoder) run(code *opcode) error {
|
|||
if ptr == 0 || header.Data == 0 {
|
||||
e.encodeNull()
|
||||
} else {
|
||||
s := base64.StdEncoding.EncodeToString(e.ptrToBytes(code.ptr))
|
||||
b := e.ptrToBytes(code.ptr)
|
||||
encodedLen := base64.StdEncoding.EncodedLen(len(b))
|
||||
e.encodeByte('"')
|
||||
e.encodeBytes(*(*[]byte)(unsafe.Pointer(&s)))
|
||||
buf := make([]byte, encodedLen)
|
||||
base64.StdEncoding.Encode(buf, b)
|
||||
e.encodeBytes(buf)
|
||||
e.encodeByte('"')
|
||||
}
|
||||
code = code.next
|
||||
|
|
Loading…
Reference in New Issue