aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/api
diff options
context:
space:
mode:
authorFilip Petkovski <filip.petkovsky@gmail.com>2025-06-23 11:47:21 +0000
committerGopher Robot <gobot@golang.org>2025-07-24 09:01:15 -0700
commit6536a9354728523f7ac3627f558ba3f51163e72c (patch)
tree58588b17878f5cbf3a050611ce23edebfe890e90 /src/cmd/api
parentefc37e97c0f358f3cffe7ca2b78c743470345189 (diff)
downloadgo-6536a9354728523f7ac3627f558ba3f51163e72c.tar.xz
encoding/json/jsontext: preserve buffer capacity in Decoder.Reset
The Decoder.Reset method is not preserving the internal buffer between resets, causing buffer capacity to be lost and resulting in unnecessary allocations when reusing decoders. This is particularly problematic when decoding many small messages. This commit fixes the Reset method to preserve the internal buffer. It makes sure aliasing is removed if the buffer currently points to an internal byte slice of a bytes.Buffer. It adds a TestDecoderReset test structured into subtests to better validate the different scenarios. Change-Id: Ia685bff47034598224489173bb7f2ffd48e89da5 GitHub-Last-Rev: 462ddc936409ee3da6d75def7d9de59eb3c65f8d GitHub-Pull-Request: golang/go#74120 Reviewed-on: https://go-review.googlesource.com/c/go/+/681177 Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: 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> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Diffstat (limited to 'src/cmd/api')
0 files changed, 0 insertions, 0 deletions