]> Cypherpunks repositories - gostls13.git/commit
go/printer, gofmt: 20 to 30% faster gofmt
authorRobert Griesemer <gri@golang.org>
Tue, 22 Nov 2011 23:12:34 +0000 (15:12 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 22 Nov 2011 23:12:34 +0000 (15:12 -0800)
commita0e54aaffa3d67b3caf9a30ffa1d0b1f359d34b1
tree55e1857fcce073fb2b83305979df48992b9de036
parent57ed39fd3bca9c69c32e55eb0a1873ab7f20bcfc
go/printer, gofmt: 20 to 30% faster gofmt

Buffer intermediate output via a bytes.Buffer and thus avoid
calling through the entire Writer stack for every item printed.
There is more opportunity for improvements along the same lines.

Before (best of 3 runs):
- printer.BenchmarkPrint       50   47959760 ns/op
- time gofmt -l $GOROOT/src       real   0m11.517s

After (best of 3 runs):
- printer.BenchmarkPrint       50   32056640 ns/op (= -33%)
- time gofmt -l $GOROOT/src       real   0m9.070s       (= -21%)

R=r
CC=golang-dev
https://golang.org/cl/5432054
src/pkg/go/printer/nodes.go
src/pkg/go/printer/printer.go