go/printer: avoid copying bytes when counting node sizes
go/printer: avoid copying bytes when counting node sizes

When making the recursive call to fprint,
we just need to know how many bytes were written
and whether multiple lines were written.

We don't need a buffer to accomplish those;
a custom writer can keep track of the two in a cheap way,
avoiding the allocation of a byte slice and copying bytes.

	name      old time/op    new time/op    delta
	Print-16    6.28ms ± 2%    6.12ms ± 1%  -2.50%  (p=0.000 n=10+9)

	name      old speed      new speed      delta
	Print-16  8.26MB/s ± 3%  8.47MB/s ± 1%  +2.56%  (p=0.000 n=10+9)

	name      old alloc/op   new alloc/op   delta
	Print-16     483kB ± 0%     443kB ± 0%  -8.20%  (p=0.000 n=10+10)

	name      old allocs/op  new allocs/op  delta
	Print-16     17.8k ± 0%     17.3k ± 0%  -2.31%  (p=0.000 n=9+10)

Change-Id: Ib8411ae6738a2acae6af6d185da71727ce2eb97a
Reviewed-on: https://go-review.googlesource.com/c/go/+/412555
Reviewed-by: Robert Griesemer <a6752097faebf1f02d80107d77a9be009089afe3@google.com>
Reviewed-by: Than McIntosh <4b2922593166fc595a9b1a408f34f5d3817fe9d2@google.com>
TryBot-Result: Gopher Robot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Run-TryBot: Daniel Martí <29bf28b42a938ace12a5819da4ed4ba03d82f315@mvdan.cc>

golang/go,golang/go,golang/go,golang/go,golang/go,golang/go,golang/go,golang/go