]> Cypherpunks repositories - gostls13.git/commit
fmt: recycle printers with large buffers
authorCarlo Alberto Ferraris <cafxx@strayorange.com>
Thu, 1 Sep 2022 05:06:55 +0000 (14:06 +0900)
committerDaniel Martí <mvdan@mvdan.cc>
Sat, 3 Sep 2022 15:45:36 +0000 (15:45 +0000)
commitf798dc682539df0bc60b30bedce9d6f5d5192d47
tree61bfa798e12c6bb316a8a7faa8b9652715f1d535
parent9fc09d2ffb4384579998b5046a1d4aee32c5ca17
fmt: recycle printers with large buffers

Previously when a printer had a large buffer we dropped both
the buffer and the printer. There is no need to drop the printer
in this case, as a printer with a nil buffer is valid. So we
just drop the buffer and recycle the printer anyway.
This saves one allocation in case the buffer is over the limit.

Also tighten some of the tests for other unrelated cases.

Change-Id: Iba1b6a71ca4691464b8c68ab0b6ab0d4d5d6168c
Reviewed-on: https://go-review.googlesource.com/c/go/+/427395
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/fmt/fmt_test.go
src/fmt/print.go