diff options
| author | thepudds1460 <thepudds1460@gmail.com> | 2025-12-10 23:33:26 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-12-11 15:13:19 -0800 |
| commit | c0c5893de85080ac440f36c3e18a67a6435f742f (patch) | |
| tree | e0e8ca0619b476a173898e9362f224b8605b1a9d | |
| parent | d2ec125e9be7c95f31f125fe4355c8d81d4980ff (diff) | |
| download | go-x-website-c0c5893de85080ac440f36c3e18a67a6435f742f.tar.xz | |
_content/doc/go1.26.md: add io.ReadAll and fmt.Errorf optimizations
We certainly don't need to document every optimization in the release
notes, but these two CLs I had sent seem more worthwhile to include
given people empirically were avoiding two relatively fundamental
APIs over performance concerns.
For io.ReadAll, people were for example posting things like
"io.ReadAll is documented to be inefficient" on different issues
on various open source projects. See https://go.dev/cl/722500 for
additional details.
For fmt.Errorf, I believe fmt.Errorf("foo") has been considered
by the core Go team to be perfectly fine, but that did not stop a
steady drip of CLs seeking to remove instances for performance reasons,
or linters that complained while citing performance, and so on.
See https://go.dev/cl/708836 for some additional discussion.
Also, it's nice when the simpler and more idiomatic user code has
the same or better performance than more complex code.
Change-Id: I409b495f1cc514588fb2160a7f36cd9bf1ce03e5
Reviewed-on: https://go-review.googlesource.com/c/website/+/729261
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Keith Randall <khr@golang.org>
| -rw-r--r-- | _content/doc/go1.26.md | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/_content/doc/go1.26.md b/_content/doc/go1.26.md index 5c4263d7..cb1371c6 100644 --- a/_content/doc/go1.26.md +++ b/_content/doc/go1.26.md @@ -410,6 +410,12 @@ Additional `R_LARCH_*` constants from [LoongArch ELF psABI v20250521](https://gi The new [`AsType`](/pkg/errors#AsType) function is a generic version of [`As`](/pkg/errors#As). It is type-safe, faster, and, in most cases, easier to use. +#### [`fmt`](/pkg/fmt/) + +<!-- go.dev/cl/708836 --> +For unformatted strings, `fmt.Errorf("x")` now allocates less and generally matches +the allocations for `errors.New("x")`. + #### [`go/ast`](/pkg/go/ast/) The new [`ParseDirective`](/pkg/go/ast#ParseDirective) function parses [directive @@ -445,6 +451,13 @@ regardless of GODEBUG setting or go.mod language version. The JPEG encoder and decoder have been replaced with new, faster, more accurate implementations. Code that expects specific bit-for-bit outputs from the encoder or decoder may need to be updated. +#### [`io`](/pkg/io/) + +<!-- go.dev/cl/722500 --> +[ReadAll](/pkg/io#ReadAll) now allocates less intermediate memory and returns a minimally sized +final slice. It is often about two times faster while typically allocating around half +as much total memory, with more benefit for larger inputs. + #### [`log/slog`](/pkg/log/slog/) The [`NewMultiHandler`](/pkg/log/slog#NewMultiHandler) function creates a |
