1
0
mirror of https://github.com/golang/go synced 2024-11-05 15:06:09 -07:00
go/src/fmt
Carlo Alberto Ferraris f798dc6825 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>
2022-09-03 15:45:36 +00:00
..
doc.go all: gofmt main repo 2022-04-11 16:34:30 +00:00
errors_test.go
errors.go all: gofmt -w -r 'interface{} -> any' src 2021-12-13 18:45:54 +00:00
example_test.go
export_test.go
fmt_test.go fmt: recycle printers with large buffers 2022-09-03 15:45:36 +00:00
format.go fmt: use “truncateString” not “truncate” in method doc 2021-03-13 18:02:24 +00:00
gostringer_example_test.go
print.go fmt: recycle printers with large buffers 2022-09-03 15:45:36 +00:00
scan_test.go all: gofmt -w -r 'interface{} -> any' src 2021-12-13 18:45:54 +00:00
scan.go all: gofmt -w -r 'interface{} -> any' src 2021-12-13 18:45:54 +00:00
state_test.go fmt: add a function to recover the original format string given a State 2022-08-06 09:19:31 +00:00
stringer_example_test.go
stringer_test.go