aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/gob
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2023-08-16 21:27:15 -0700
committerGopher Robot <gobot@golang.org>2023-08-19 22:25:23 +0000
commite8cdab5c494716e547d2b84b68d46680e35a7a9f (patch)
tree6d6c704c354a6c2137d95824098e6f34d6c0c496 /src/encoding/gob
parente47fad515d50f685677b7418ae3fc24a0849f663 (diff)
downloadgo-e8cdab5c494716e547d2b84b68d46680e35a7a9f.tar.xz
encoding: optimize growth behavior in Encoding.AppendDecode
The Encoding.DecodedLen API only returns the maximum length of the expected decoded output, since it does not know about padding. Since we have the input, we can do better by computing the input length without padding, and then perform the DecodedLen calculation as if there were no padding. This avoids over-growing the destination slice if possible. Over-growth is still possible since the input may contain ignore characters like newlines and carriage returns, but those a rarely encountered in practice. Change-Id: I38b8f91de1f4fbd3a7128c491a25098bd385cf74 Reviewed-on: https://go-review.googlesource.com/c/go/+/520267 Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/encoding/gob')
0 files changed, 0 insertions, 0 deletions