mirror of
https://github.com/golang/go
synced 2024-11-22 22:20:03 -07:00
encoding/json: use base64.Encoding.AppendEncode
For #53693 Change-Id: I6a428a4a10a2e2efa03296f539e190f0743c1f46 Reviewed-on: https://go-review.googlesource.com/c/go/+/520755 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com>
This commit is contained in:
parent
ce16086345
commit
3419a0aec1
@ -781,15 +781,11 @@ func encodeByteSlice(e *encodeState, v reflect.Value, _ encOpts) {
|
||||
e.WriteString("null")
|
||||
return
|
||||
}
|
||||
s := v.Bytes()
|
||||
encodedLen := base64.StdEncoding.EncodedLen(len(s))
|
||||
e.Grow(len(`"`) + encodedLen + len(`"`))
|
||||
|
||||
// TODO(https://go.dev/issue/53693): Use base64.Encoding.AppendEncode.
|
||||
s := v.Bytes()
|
||||
b := e.AvailableBuffer()
|
||||
b = append(b, '"')
|
||||
base64.StdEncoding.Encode(b[len(b):][:encodedLen], s)
|
||||
b = b[:len(b)+encodedLen]
|
||||
b = base64.StdEncoding.AppendEncode(b, s)
|
||||
b = append(b, '"')
|
||||
e.Write(b)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user