diff options
| author | Joe Tsai <joetsai@digital-static.net> | 2025-06-24 19:00:23 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-06-30 16:52:53 -0700 |
| commit | 86fca3dcb63157b8e45e565e821e7fb098fcf368 (patch) | |
| tree | 0698599d833292602cc6abaf7700321727151bac /src/encoding/json/jsontext | |
| parent | 6bd9944c9a9fb6b1da6288358b0620218d621441 (diff) | |
| download | go-86fca3dcb63157b8e45e565e821e7fb098fcf368.tar.xz | |
encoding/json/jsontext: use bytes.Buffer.AvailableBuffer
This logic was added in October, 2021:
https://github.com/go-json-experiment/json/commit/0b3bd4e1ed96587be346b7f964d6bb3fcfed65f4
before the introduction of bytes.Buffer.AvailableBuffer in March, 2023.
https://go.dev/cl/474635
Updates #71845
Change-Id: I96800e1ba8fce15cc78316779db4ddcd4fe1d510
Reviewed-on: https://go-review.googlesource.com/c/go/+/685136
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/encoding/json/jsontext')
| -rw-r--r-- | src/encoding/json/jsontext/encode.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/encoding/json/jsontext/encode.go b/src/encoding/json/jsontext/encode.go index bb9a41f0f6..562d217fef 100644 --- a/src/encoding/json/jsontext/encode.go +++ b/src/encoding/json/jsontext/encode.go @@ -114,7 +114,7 @@ func (e *encoderState) reset(b []byte, w io.Writer, opts ...Options) { e.state.reset() e.encodeBuffer = encodeBuffer{Buf: b, wr: w, bufStats: e.bufStats} if bb, ok := w.(*bytes.Buffer); ok && bb != nil { - e.Buf = bb.Bytes()[bb.Len():] // alias the unused buffer of bb + e.Buf = bb.AvailableBuffer() // alias the unused buffer of bb } opts2 := jsonopts.Struct{} // avoid mutating e.Struct in case it is part of opts opts2.Join(opts...) |
